mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-11 12:12:29 +00:00
2965 lines
98 KiB
HTML
2965 lines
98 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content=
|
|
"text/html; charset=iso-8859-1">
|
|
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
|
<title>Matrix Proxies</title>
|
|
</head>
|
|
<body bgcolor="#ffffff">
|
|
<h1><img src="c++boost.gif" alt="c++boost.gif" align="Center">
|
|
Matrix Proxies</h1>
|
|
|
|
<h2><a name="matrix_row"></a> Matrix Row</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_row<M></code> allows
|
|
addressing a row of a matrix.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i) {<br>
|
|
matrix_row<matrix<double> > mr (m, i);<br>
|
|
for (unsigned j = 0; j < mr.size (); ++ j)<br>
|
|
mr (j) = 3 * i + j;<br>
|
|
std::cout << mr << std::endl;<br>
|
|
}<br>
|
|
}
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>M</code> </td>
|
|
<td>The type of matrix referenced.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p><a href="expression.htm#vector_expression">Vector Expression</a>
|
|
.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of <a href=
|
|
"expression.htm#vector_expression">Vector Expression</a> .</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p><code>vector_expression<matrix_row<M> ></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_row (matrix_type &data, size_type
|
|
i)</code></td>
|
|
<td>Constructs a sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator () (size_type i)
|
|
const</code></td>
|
|
<td>Returns the value of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator () (size_type i)</code></td>
|
|
<td>Returns a reference of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_row &operator = (const matrix_row
|
|
&mr)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_row &assign_temporary (matrix_row
|
|
&mr)</code></td>
|
|
<td>Assigns a temporary. May change the matrix row <code>mr</code>
|
|
.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_row &operator = (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>The extended assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_row &assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Assigns a vector expression to the sub vector. Left and right
|
|
hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_row &operator += (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Adds the vector expression to
|
|
the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_row &plus_assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Adds a vector expression to the sub vector. Left and right hand
|
|
side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_row &operator -= (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Subtracts the vector expression
|
|
from the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_row &minus_assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Subtracts a vector expression from the sub vector. Left and
|
|
right hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_row &operator *= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub vector with
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_row &operator /= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Divides the sub vector through
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (matrix_row &mr)</code></td>
|
|
<td>Swaps the contents of the sub vectors.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator begin () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the beginning
|
|
of the <code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator end () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the end of
|
|
the <code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rbegin () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rend () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
end of the reversed <code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rbegin ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_row</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rend ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the end of
|
|
the reversed <code>matrix_row</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Matrix based row vector class<br>
|
|
template<class M><br>
|
|
class matrix_row:<br>
|
|
public vector_expression<matrix_row<M> > {<br>
|
|
public:<br>
|
|
typedef const M const_matrix_type;<br>
|
|
typedef M matrix_type;<br>
|
|
typedef typename M::size_type size_type;<br>
|
|
typedef typename M::difference_type difference_type;<br>
|
|
typedef typename M::value_type value_type;<br>
|
|
typedef typename M::const_reference const_reference;<br>
|
|
typedef typename M::reference reference;<br>
|
|
typedef typename M::const_pointer const_pointer;<br>
|
|
typedef typename M::pointer pointer;<br>
|
|
typedef const vector_const_reference<const matrix_row<matrix_type> > const_closure_type;<br>
|
|
typedef vector_reference<matrix_row<matrix_type> > closure_type;<br>
|
|
typedef typename M::const_iterator2 const_iterator_type;<br>
|
|
typedef typename M::iterator2 iterator_type;<br>
|
|
typedef typename storage_restrict_traits<typename M::storage_category,<br>
|
|
dense_proxy_tag>::storage_category storage_category;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
matrix_row ();<br>
|
|
matrix_row (matrix_type &data, size_type i);<br>
|
|
<br>
|
|
// Accessors<br>
|
|
size_type size () const;<br>
|
|
const_matrix_type &data () const;<br>
|
|
matrix_type &data ();<br>
|
|
<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type j) const;<br>
|
|
reference operator () (size_type j);<br>
|
|
<br>
|
|
const_reference operator [] (size_type j) const;<br>
|
|
reference operator [] (size_type j);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
matrix_row &operator = (const matrix_row &mr);<br>
|
|
matrix_row &assign_temporary (matrix_row &mr);<br>
|
|
template<class AE><br>
|
|
matrix_row &operator = (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_row &assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_row &operator += (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_row &plus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_row &operator -= (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_row &minus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AT><br>
|
|
matrix_row &operator *= (const AT &at);<br>
|
|
template<class AT><br>
|
|
matrix_row &operator /= (const AT &at);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (matrix_row &mr);<br>
|
|
friend void swap (matrix_row &mr1, matrix_row &mr2);<br>
|
|
<br>
|
|
class const_iterator;<br>
|
|
class iterator;<br>
|
|
<br>
|
|
// Element lookup<br>
|
|
const_iterator find_first (size_type j) const;<br>
|
|
iterator find_first (size_type j);<br>
|
|
const_iterator find_last (size_type j) const;<br>
|
|
iterator find_last (size_type j);<br>
|
|
<br>
|
|
// Iterators simply are pointers.<br>
|
|
<br>
|
|
class const_iterator:<br>
|
|
public container_const_reference<matrix_row>,<br>
|
|
public random_access_iterator_base<const_iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename const_iterator_type::iterator_category iterator_category;<br>
|
|
typedef typename const_iterator_type::difference_type difference_type;<br>
|
|
typedef typename const_iterator_type::value_type value_type;<br>
|
|
typedef typename const_iterator_type::reference reference;<br>
|
|
typedef typename const_iterator_type::pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator ();<br>
|
|
const_iterator (const matrix_row &mr, const const_iterator_type &it);<br>
|
|
const_iterator (const iterator &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator &operator ++ ();<br>
|
|
const_iterator &operator -- ();<br>
|
|
const_iterator &operator += (difference_type n);<br>
|
|
const_iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator &operator = (const const_iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator &it) const;<br>
|
|
bool operator <(const const_iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
class iterator:<br>
|
|
public container_reference<matrix_row>,<br>
|
|
public random_access_iterator_base<iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename iterator_type::iterator_category iterator_category;<br>
|
|
typedef typename iterator_type::difference_type difference_type;<br>
|
|
typedef typename iterator_type::value_type value_type;<br>
|
|
typedef typename iterator_type::reference reference;<br>
|
|
typedef typename iterator_type::pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator ();<br>
|
|
iterator (matrix_row &mr, const iterator_type &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator &operator ++ ();<br>
|
|
iterator &operator -- ();<br>
|
|
iterator &operator += (difference_type n);<br>
|
|
iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator &operator = (const iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator &it) const;<br>
|
|
bool operator <(const iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator begin ();<br>
|
|
iterator end ();<br>
|
|
<br>
|
|
// Reverse iterator<br>
|
|
<br>
|
|
typedef reverse_iterator_base<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
<br>
|
|
typedef reverse_iterator_base<iterator> reverse_iterator;<br>
|
|
<br>
|
|
reverse_iterator rbegin ();<br>
|
|
reverse_iterator rend ();<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h3>Projections</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre>
|
|
<code>template<class M><br>
|
|
matrix_row<M> row (M &data, std::size_t i);<br>
|
|
template<class M><br>
|
|
const matrix_row<const M> row (const M &data, std::size_t i);</code>
|
|
</pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The free <code>row</code> functions support the construction of
|
|
matrix rows.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<ul>
|
|
<li><code>M</code> is a model of <a href=
|
|
"expression.htm#matrix_expression">Matrix Expression</a> .</li>
|
|
</ul>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<ul type="Disc">
|
|
<li><code>i < data.size1 ()</code></li>
|
|
</ul>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Linear depending from the size of the row.</p>
|
|
|
|
<h4>Examples</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i) {<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j)<br>
|
|
row (m, i) (j) = 3 * i + j;<br>
|
|
std::cout << row (m, i) << std::endl;<br>
|
|
}<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h2><a name="matrix_column"></a> Matrix Column</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_column<M></code> allows
|
|
addressing a column of a matrix.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j) {<br>
|
|
matrix_column<matrix<double> > mc (m, j);<br>
|
|
for (unsigned i = 0; i < mc.size (); ++ i)<br>
|
|
mc (i) = 3 * i + j;<br>
|
|
std::cout << mc << std::endl;<br>
|
|
}<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>M</code> </td>
|
|
<td>The type of matrix referenced.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p><a href="expression.htm#vector_expression">Vector Expression</a>
|
|
.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of <a href=
|
|
"expression.htm#vector_expression">Vector Expression</a> .</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p><code>vector_expression<matrix_column<M>
|
|
></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_column (matrix_type &data, size_type
|
|
j)</code></td>
|
|
<td>Constructs a sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator () (size_type i)
|
|
const</code></td>
|
|
<td>Returns the value of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator () (size_type i)</code></td>
|
|
<td>Returns a reference of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_column &operator = (const matrix_column
|
|
&mc)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_column &assign_temporary (matrix_column
|
|
&mc)</code></td>
|
|
<td>Assigns a temporary. May change the matrix column
|
|
<code>mc</code> .</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_column &operator = (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>The extended assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_column &assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Assigns a vector expression to the sub vector. Left and right
|
|
hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_column &operator += (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Adds the vector expression to
|
|
the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_column &plus_assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Adds a vector expression to the sub vector. Left and right hand
|
|
side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_column &operator -= (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Subtracts the vector expression
|
|
from the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_column &minus_assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Subtracts a vector expression from the sub vector. Left and
|
|
right hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_column &operator *= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub vector with
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_column &operator /= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Divides the sub vector through
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (matrix_column &mc)</code></td>
|
|
<td>Swaps the contents of the sub vectors.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator begin () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the beginning
|
|
of the <code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator end () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the end of
|
|
the <code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rbegin () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rend () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
end of the reversed <code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rbegin ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_column</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rend ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the end of
|
|
the reversed <code>matrix_column</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Matrix based column vector class<br>
|
|
template<class M><br>
|
|
class matrix_column:<br>
|
|
public vector_expression<matrix_column<M> > {<br>
|
|
public: <br>
|
|
typedef const M const_matrix_type;<br>
|
|
typedef M matrix_type;<br>
|
|
typedef typename M::size_type size_type;<br>
|
|
typedef typename M::difference_type difference_type;<br>
|
|
typedef typename M::value_type value_type;<br>
|
|
typedef typename M::const_reference const_reference;<br>
|
|
typedef typename M::reference reference;<br>
|
|
typedef typename M::const_pointer const_pointer;<br>
|
|
typedef typename M::pointer pointer;<br>
|
|
typedef const vector_const_reference<const matrix_column<matrix_type> > const_closure_type;<br>
|
|
typedef vector_reference<matrix_column<matrix_type> > closure_type;<br>
|
|
typedef typename M::const_iterator1 const_iterator_type;<br>
|
|
typedef typename M::iterator1 iterator_type;<br>
|
|
typedef typename storage_restrict_traits<typename M::storage_category,<br>
|
|
dense_proxy_tag>::storage_category storage_category;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
matrix_column ();<br>
|
|
matrix_column (matrix_type &data, size_type j);<br>
|
|
<br>
|
|
// Accessors<br>
|
|
size_type size () const;<br>
|
|
const_matrix_type &data () const;<br>
|
|
matrix_type &data ();<br>
|
|
<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i) const;<br>
|
|
reference operator () (size_type i);<br>
|
|
<br>
|
|
const_reference operator [] (size_type i) const;<br>
|
|
reference operator [] (size_type i);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
matrix_column &operator = (const matrix_column &mc);<br>
|
|
matrix_column &assign_temporary (matrix_column &mc);<br>
|
|
template<class AE><br>
|
|
matrix_column &operator = (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_column &assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_column &operator += (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_column &plus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_column &operator -= (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_column &minus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AT><br>
|
|
matrix_column &operator *= (const AT &at);<br>
|
|
template<class AT><br>
|
|
matrix_column &operator /= (const AT &at);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (matrix_column &mc);<br>
|
|
friend void swap (matrix_column &mc1, matrix_column &mc2);<br>
|
|
<br>
|
|
class const_iterator;<br>
|
|
class iterator;<br>
|
|
<br>
|
|
// Element lookup<br>
|
|
const_iterator find_first (size_type i) const;<br>
|
|
iterator find_first (size_type i);<br>
|
|
const_iterator find_last (size_type i) const;<br>
|
|
iterator find_last (size_type i);<br>
|
|
<br>
|
|
// Iterators simply are pointers.<br>
|
|
<br>
|
|
class const_iterator:<br>
|
|
public container_const_reference<matrix_column>,<br>
|
|
public random_access_iterator_base<const_iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename const_iterator_type::iterator_category iterator_category;<br>
|
|
typedef typename const_iterator_type::difference_type difference_type;<br>
|
|
typedef typename const_iterator_type::value_type value_type;<br>
|
|
typedef typename const_iterator_type::reference reference;<br>
|
|
typedef typename const_iterator_type::pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator ();<br>
|
|
const_iterator (const matrix_column &mc, const const_iterator_type &it);<br>
|
|
const_iterator (const iterator &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator &operator ++ ();<br>
|
|
const_iterator &operator -- ();<br>
|
|
const_iterator &operator += (difference_type n);<br>
|
|
const_iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator &operator = (const const_iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator &it) const;<br>
|
|
bool operator <(const const_iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
class iterator:<br>
|
|
public container_reference<matrix_column>,<br>
|
|
public random_access_iterator_base<iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename iterator_type::iterator_category iterator_category;<br>
|
|
typedef typename iterator_type::difference_type difference_type;<br>
|
|
typedef typename iterator_type::value_type value_type;<br>
|
|
typedef typename iterator_type::reference reference;<br>
|
|
typedef typename iterator_type::pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator ();<br>
|
|
iterator (matrix_column &mc, const iterator_type &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator &operator ++ ();<br>
|
|
iterator &operator -- ();<br>
|
|
iterator &operator += (difference_type n);<br>
|
|
iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator &operator = (const iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator &it) const;<br>
|
|
bool operator <(const iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator begin ();<br>
|
|
iterator end ();<br>
|
|
<br>
|
|
// Reverse iterator<br>
|
|
<br>
|
|
typedef reverse_iterator_base<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
<br>
|
|
typedef reverse_iterator_base<iterator> reverse_iterator;<br>
|
|
<br>
|
|
reverse_iterator rbegin ();<br>
|
|
reverse_iterator rend ();<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h3>Projections</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre>
|
|
<code>template<class M><br>
|
|
matrix_column<M> column (M &data, std::size_t j);<br>
|
|
template<class M><br>
|
|
const matrix_column<const M> column (const M &data, std::size_t j);</code>
|
|
</pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The free <code>column</code> functions support the construction
|
|
of matrix columns.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<ul>
|
|
<li><code>M</code> is a model of <a href=
|
|
"expression.htm#matrix_expression">Matrix Expression</a> .</li>
|
|
</ul>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<ul type="Disc">
|
|
<li><code>j < data.size2 ()</code></li>
|
|
</ul>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Linear depending from the size of the column.</p>
|
|
|
|
<h4>Examples</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j) {<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i)<br>
|
|
column (m, j) (i) = 3 * i + j;<br>
|
|
std::cout << column (m, j) << std::endl;<br>
|
|
}<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h2><a name="vector_range"></a> Vector Range</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_vector_range<M></code>
|
|
allows addressing a sub vector of a matrix.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i)<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j)<br>
|
|
m (i, j) = 3 * i + j;<br>
|
|
<br>
|
|
matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3));<br>
|
|
std::cout << mvr << std::endl;<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>M</code> </td>
|
|
<td>The type of matrix referenced.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p><a href="expression.htm#vector_expression">Vector Expression</a>
|
|
.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of <a href=
|
|
"expression.htm#vector_expression">Vector Expression</a> .</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p><code>vector_expression<matrix_vector_range<M>
|
|
></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_vector_range (matrix_type &data,<br>
|
|
const range &r1, const range &r2)</code></td>
|
|
<td>Constructs a sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator () (size_type i)
|
|
const</code></td>
|
|
<td>Returns the value of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator () (size_type i)</code></td>
|
|
<td>Returns a reference of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_vector_range &operator = (const
|
|
matrix_vector_range &mvr)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_vector_range &assign_temporary
|
|
(matrix_vector_range &mvr)</code></td>
|
|
<td>Assigns a temporary. May change the matrix vector range
|
|
<code>mvr</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_range &operator = (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>The extended assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_range &assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Assigns a vector expression to the sub vector. Left and right
|
|
hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_range &operator += (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>A computed assignment operator. Adds the vector expression to
|
|
the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_range &plus_assign (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>Adds a vector expression to the sub vector. Left and right hand
|
|
side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_range &operator -= (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>A computed assignment operator. Subtracts the vector expression
|
|
from the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_range &minus_assign (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>Subtracts a vector expression from the sub vector. Left and
|
|
right hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_vector_range &operator *= (const AT
|
|
&at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub vector with
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_vector_range &operator /= (const AT
|
|
&at)</code></td>
|
|
<td>A computed assignment operator. Divides the sub vector through
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (matrix_vector_range &mvr)</code></td>
|
|
<td>Swaps the contents of the sub vectors.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator begin () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the beginning
|
|
of the <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator end () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the end of
|
|
the <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rbegin () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
beginning of the <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rend () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
end of the reversed <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rbegin ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rend ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the end of
|
|
the reversed <code>matrix_vector_range</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Matrix based vector range class<br>
|
|
template<class M><br>
|
|
class matrix_vector_range:<br>
|
|
public vector_expression<matrix_vector_range<M> > {<br>
|
|
public: <br>
|
|
typedef const M const_matrix_type;<br>
|
|
typedef M matrix_type;<br>
|
|
typedef typename M::size_type size_type;<br>
|
|
typedef typename M::difference_type difference_type;<br>
|
|
typedef typename M::value_type value_type;<br>
|
|
typedef typename M::const_reference const_reference;<br>
|
|
typedef typename M::reference reference;<br>
|
|
typedef typename M::const_pointer const_pointer;<br>
|
|
typedef typename M::pointer pointer;<br>
|
|
typedef const vector_const_reference<const matrix_vector_range<matrix_type> > const_closure_type;<br>
|
|
typedef vector_reference<matrix_vector_range<matrix_type> > closure_type;<br>
|
|
typedef range::const_iterator const_iterator1_type;<br>
|
|
typedef range::const_iterator iterator1_type;<br>
|
|
typedef range::const_iterator const_iterator2_type;<br>
|
|
typedef range::const_iterator iterator2_type;<br>
|
|
typedef typename storage_restrict_traits<typename M::storage_category,<br>
|
|
dense_proxy_tag>::storage_category storage_category;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
matrix_vector_range ();<br>
|
|
matrix_vector_range (matrix_type &data, const range &r1, const range &r2);<br>
|
|
<br>
|
|
// Accessors<br>
|
|
size_type size () const;<br>
|
|
const_matrix_type &data () const;<br>
|
|
matrix_type &data ();<br>
|
|
<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i) const;<br>
|
|
reference operator () (size_type i);<br>
|
|
<br>
|
|
const_reference operator [] (size_type i) const;<br>
|
|
reference operator [] (size_type i);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
matrix_vector_range &operator = (const matrix_vector_range &mvr);<br>
|
|
matrix_vector_range &assign_temporary (matrix_vector_range &mvr);<br>
|
|
template<class AE><br>
|
|
matrix_vector_range &operator = (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_range &assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_range &operator += (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_range &plus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_range &operator -= (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_range &minus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AT><br>
|
|
matrix_vector_range &operator *= (const AT &at);<br>
|
|
template<class AT><br>
|
|
matrix_vector_range &operator /= (const AT &at);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (matrix_vector_range &mvr);<br>
|
|
friend void swap (matrix_vector_range &mvr1, matrix_vector_range &mvr2);<br>
|
|
<br>
|
|
class const_iterator;<br>
|
|
class iterator;<br>
|
|
<br>
|
|
// Element lookup<br>
|
|
const_iterator find_first (size_type i) const;<br>
|
|
iterator find_first (size_type i);<br>
|
|
const_iterator find_last (size_type i) const;<br>
|
|
iterator find_last (size_type i);<br>
|
|
<br>
|
|
// Iterators simply are indices.<br>
|
|
<br>
|
|
class const_iterator:<br>
|
|
public container_const_reference<matrix_vector_range>,<br>
|
|
public random_access_iterator_base<const_iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename restrict_traits<typename M::const_iterator1::iterator_category,<br>
|
|
typename M::const_iterator2::iterator_category>::iterator_category iterator_category;<br>
|
|
typedef typename matrix_vector_range::difference_type difference_type;<br>
|
|
typedef typename matrix_vector_range::value_type value_type;<br>
|
|
typedef typename matrix_vector_range::const_reference reference;<br>
|
|
typedef typename matrix_vector_range::const_pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator ();<br>
|
|
const_iterator (const matrix_vector_range &mvr, const const_iterator1_type &it1, const const_iterator2_type &it2);<br>
|
|
const_iterator (const iterator &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator &operator ++ ();<br>
|
|
const_iterator &operator -- ();<br>
|
|
const_iterator &operator += (difference_type n);<br>
|
|
const_iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator &operator = (const const_iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator &it) const;<br>
|
|
bool operator <(const const_iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
class iterator:<br>
|
|
public container_reference<matrix_vector_range>,<br>
|
|
public random_access_iterator_base<iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename restrict_traits<typename M::iterator1::iterator_category,<br>
|
|
typename M::iterator2::iterator_category>::iterator_category iterator_category;<br>
|
|
typedef typename matrix_vector_range::difference_type difference_type;<br>
|
|
typedef typename matrix_vector_range::value_type value_type;<br>
|
|
typedef typename matrix_vector_range::reference reference;<br>
|
|
typedef typename matrix_vector_range::pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator ();<br>
|
|
iterator (matrix_vector_range &mvr, const iterator1_type &it1, const iterator2_type &it2);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator &operator ++ ();<br>
|
|
iterator &operator -- ();<br>
|
|
iterator &operator += (difference_type n);<br>
|
|
iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator &operator = (const iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator &it) const;<br>
|
|
bool operator <(const iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator begin ();<br>
|
|
iterator end ();<br>
|
|
<br>
|
|
// Reverse iterator<br>
|
|
<br>
|
|
typedef reverse_iterator_base<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
<br>
|
|
typedef reverse_iterator_base<iterator> reverse_iterator;<br>
|
|
<br>
|
|
reverse_iterator rbegin ();<br>
|
|
reverse_iterator rend ();<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h2><a name="vector_slice"></a> Vector Slice</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_vector_slice<M></code>
|
|
allows addressing a sliced sub vector of a matrix.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i)<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j)<br>
|
|
m (i, j) = 3 * i + j;<br>
|
|
<br>
|
|
matrix_vector_slice<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3));<br>
|
|
std::cout << mvs << std::endl;<br>
|
|
}
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>M</code> </td>
|
|
<td>The type of matrix referenced.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p><a href="expression.htm#vector_expression">Vector Expression</a>
|
|
.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of <a href=
|
|
"expression.htm#vector_expression">Vector Expression</a> .</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p><code>vector_expression<matrix_vector_slice<M>
|
|
></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_vector_slice (matrix_type &data,<br>
|
|
const slice &s1, const slice &s2)</code></td>
|
|
<td>Constructs a sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator () (size_type i)
|
|
const</code></td>
|
|
<td>Returns the value of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator () (size_type i)</code></td>
|
|
<td>Returns a reference of the <code>i</code>-th element.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_vector_slice &operator = (const
|
|
matrix_vector_slice &mvs)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_vector_slice &assign_temporary
|
|
(matrix_vector_slice &mvs)</code></td>
|
|
<td>Assigns a temporary. May change the matrix vector slice
|
|
<code>vs</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_slice &operator = (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>The extended assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_slice &assign (const vector_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Assigns a vector expression to the sub vector. Left and right
|
|
hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_slice &operator += (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>A computed assignment operator. Adds the vector expression to
|
|
the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_slice &plus_assign (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>Adds a vector expression to the sub vector. Left and right hand
|
|
side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_slice &operator -= (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>A computed assignment operator. Subtracts the vector expression
|
|
from the sub vector.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_vector_slice &minus_assign (const
|
|
vector_expression<AE> &ae)</code></td>
|
|
<td>Subtracts a vector expression from the sub vector. Left and
|
|
right hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_vector_slice &operator *= (const AT
|
|
&at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub vector with
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_vector_slice &operator /= (const AT
|
|
&at)</code></td>
|
|
<td>A computed assignment operator. Divides the sub vector through
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (matrix_vector_slice &mvs)</code></td>
|
|
<td>Swaps the contents of the sub vectors.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator begin () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the beginning
|
|
of the <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator end () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the end of
|
|
the <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator begin ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the beginning of
|
|
the <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator end ()</code> </td>
|
|
<td>Returns a <code>iterator</code> pointing to the end of the
|
|
<code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rbegin () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator rend () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator</code> pointing to the
|
|
end of the reversed <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rbegin ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the
|
|
beginning of the reversed <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator rend ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator</code> pointing to the end of
|
|
the reversed <code>matrix_vector_slice</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Matrix based vector slice class<br>
|
|
template<class M><br>
|
|
class matrix_vector_slice:<br>
|
|
public vector_expression<matrix_vector_slice<M> > {<br>
|
|
public: <br>
|
|
typedef const M const_matrix_type;<br>
|
|
typedef M matrix_type;<br>
|
|
typedef typename M::size_type size_type;<br>
|
|
typedef typename M::difference_type difference_type;<br>
|
|
typedef typename M::value_type value_type;<br>
|
|
typedef typename M::const_reference const_reference;<br>
|
|
typedef typename M::reference reference;<br>
|
|
typedef typename M::const_pointer const_pointer;<br>
|
|
typedef typename M::pointer pointer;<br>
|
|
typedef const vector_const_reference<const matrix_vector_slice<matrix_type> > const_closure_type;<br>
|
|
typedef vector_reference<matrix_vector_slice<matrix_type> > closure_type;<br>
|
|
typedef slice::const_iterator const_iterator1_type;<br>
|
|
typedef slice::const_iterator iterator1_type;<br>
|
|
typedef slice::const_iterator const_iterator2_type;<br>
|
|
typedef slice::const_iterator iterator2_type;<br>
|
|
typedef typename storage_restrict_traits<typename M::storage_category,<br>
|
|
dense_proxy_tag>::storage_category storage_category;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
matrix_vector_slice ();<br>
|
|
matrix_vector_slice (matrix_type &data, const slice &s1, const slice &s2);<br>
|
|
<br>
|
|
// Accessors<br>
|
|
size_type size () const;<br>
|
|
const_matrix_type &data () const;<br>
|
|
matrix_type &data ();<br>
|
|
<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i) const;<br>
|
|
reference operator () (size_type i);<br>
|
|
<br>
|
|
const_reference operator [] (size_type i) const;<br>
|
|
reference operator [] (size_type i);<br>
|
|
<br>
|
|
// Assignment<br>
|
|
matrix_vector_slice &operator = (const matrix_vector_slice &mvs);<br>
|
|
matrix_vector_slice &assign_temporary (matrix_vector_slice &mvs);<br>
|
|
template<class AE><br>
|
|
matrix_vector_slice &operator = (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_slice &assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_slice &operator += (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_slice &plus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_slice &operator -= (const vector_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_vector_slice &minus_assign (const vector_expression<AE> &ae);<br>
|
|
template<class AT><br>
|
|
matrix_vector_slice &operator *= (const AT &at);<br>
|
|
template<class AT><br>
|
|
matrix_vector_slice &operator /= (const AT &at);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (matrix_vector_slice &mvs);<br>
|
|
friend void swap (matrix_vector_slice &mvs1, matrix_vector_slice &mvs2);<br>
|
|
<br>
|
|
class const_iterator;<br>
|
|
class iterator;<br>
|
|
<br>
|
|
// Element lookup<br>
|
|
const_iterator find_first (size_type i) const;<br>
|
|
iterator find_first (size_type i);<br>
|
|
const_iterator find_last (size_type i) const;<br>
|
|
iterator find_last (size_type i);<br>
|
|
<br>
|
|
// Iterators simply are indices.<br>
|
|
<br>
|
|
class const_iterator:<br>
|
|
public container_const_reference<matrix_vector_slice>,<br>
|
|
public random_access_iterator_base<const_iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename restrict_traits<typename M::const_iterator1::iterator_category,<br>
|
|
typename M::const_iterator2::iterator_category>::iterator_category iterator_category;<br>
|
|
typedef typename matrix_vector_slice::difference_type difference_type;<br>
|
|
typedef typename matrix_vector_slice::value_type value_type;<br>
|
|
typedef typename matrix_vector_slice::const_reference reference;<br>
|
|
typedef typename matrix_vector_slice::const_pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator ();<br>
|
|
const_iterator (const matrix_vector_slice &mvs, const const_iterator1_type &it1, const const_iterator2_type &it2);<br>
|
|
const_iterator (const iterator &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator &operator ++ ();<br>
|
|
const_iterator &operator -- ();<br>
|
|
const_iterator &operator += (difference_type n);<br>
|
|
const_iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator &operator = (const const_iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator &it) const;<br>
|
|
bool operator <(const const_iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator begin () const;<br>
|
|
const_iterator end () const;<br>
|
|
<br>
|
|
class iterator:<br>
|
|
public container_reference<matrix_vector_slice>,<br>
|
|
public random_access_iterator_base<iterator, value_type> {<br>
|
|
public:<br>
|
|
typedef typename restrict_traits<typename M::iterator1::iterator_category,<br>
|
|
typename M::iterator2::iterator_category>::iterator_category iterator_category;<br>
|
|
typedef typename matrix_vector_slice::difference_type difference_type;<br>
|
|
typedef typename matrix_vector_slice::value_type value_type;<br>
|
|
typedef typename matrix_vector_slice::reference reference;<br>
|
|
typedef typename matrix_vector_slice::pointer pointer;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator ();<br>
|
|
iterator (matrix_vector_slice &mvs, const iterator1_type &it1, const iterator2_type &it2);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator &operator ++ ();<br>
|
|
iterator &operator -- ();<br>
|
|
iterator &operator += (difference_type n);<br>
|
|
iterator &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
// Index<br>
|
|
size_type index () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator &operator = (const iterator &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator &it) const;<br>
|
|
bool operator <(const iterator &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator begin ();<br>
|
|
iterator end ();<br>
|
|
<br>
|
|
// Reverse iterator<br>
|
|
<br>
|
|
typedef reverse_iterator_base<const_iterator> const_reverse_iterator;<br>
|
|
<br>
|
|
const_reverse_iterator rbegin () const;<br>
|
|
const_reverse_iterator rend () const;<br>
|
|
<br>
|
|
typedef reverse_iterator_base<iterator> reverse_iterator;<br>
|
|
<br>
|
|
reverse_iterator rbegin ();<br>
|
|
reverse_iterator rend ();<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h2><a name="matrix_range"></a> Matrix Range</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_range<M></code> allows
|
|
addressing a sub matrix of a matrix.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3));<br>
|
|
for (unsigned i = 0; i < mr.size1 (); ++ i)<br>
|
|
for (unsigned j = 0; j < mr.size2 (); ++ j)<br>
|
|
mr (i, j) = 3 * i + j;<br>
|
|
std::cout << mr << std::endl;<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>M</code> </td>
|
|
<td>The type of matrix referenced.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p><a href="expression.htm#matrix_expression">Matrix Expression</a>
|
|
.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of <a href=
|
|
"expression.htm#matrix_expression">Matrix Expression</a> .</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p><code>matrix_expression<matrix_range<M> ></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_range (matrix_type &data,<br>
|
|
const range &r1, const range &r2)</code></td>
|
|
<td>Constructs a sub matrix.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type start1 () const</code></td>
|
|
<td>Returns the index of the first row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size1 () const</code></td>
|
|
<td>Returns the number of rows.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type start2 () const</code></td>
|
|
<td>Returns the index of the first column.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size2 () const</code></td>
|
|
<td>Returns the number of columns.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator () (size_type i, size_type j)
|
|
const</code></td>
|
|
<td>Returns the value of the <code>j</code>-th element in the
|
|
<code>i</code>-th row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator () (size_type i, size_type
|
|
j)</code></td>
|
|
<td>Returns a reference of the <code>j</code>-th element in the
|
|
<code>i</code>-th row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_range &operator = (const matrix_range
|
|
&mr)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_range &assign_temporary (matrix_range
|
|
&mr)</code></td>
|
|
<td>Assigns a temporary. May change the matrix range
|
|
<code>mr</code> .</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_range &operator = (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>The extended assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_range &assign (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Assigns a matrix expression to the sub matrix. Left and right
|
|
hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_range &operator += (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Adds the matrix expression to
|
|
the sub matrix.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_range &plus_assign (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Adds a matrix expression to the sub matrix. Left and right hand
|
|
side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_range &operator -= (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Subtracts the matrix expression
|
|
from the sub matrix.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_range &minus_assign (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Subtracts a matrix expression from the sub matrix. Left and
|
|
right hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_range &operator *= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub matrix with
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_range &operator /= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Divides the sub matrix through
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (matrix_range &mr)</code></td>
|
|
<td>Swaps the contents of the sub matrices.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to the
|
|
beginning of the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to the end of
|
|
the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator1 begin1 ()</code> </td>
|
|
<td>Returns a <code>iterator1</code> pointing to the beginning of
|
|
the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator1 end1 ()</code> </td>
|
|
<td>Returns a <code>iterator1</code> pointing to the end of the
|
|
<code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to the
|
|
beginning of the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to the end of
|
|
the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator2 begin2 ()</code> </td>
|
|
<td>Returns a <code>iterator2</code> pointing to the beginning of
|
|
the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator2 end2 ()</code> </td>
|
|
<td>Returns a <code>iterator2</code> pointing to the end of the
|
|
<code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
|
|
beginning of the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator1 rend1 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
|
|
end of the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator1 rbegin1 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator1</code> pointing to the
|
|
beginning of the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator1 rend1 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
|
|
the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
|
|
beginning of the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator2 rend2 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
|
|
end of the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator2 rbegin2 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator2</code> pointing to the
|
|
beginning of the reversed <code>matrix_range</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator2 rend2 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
|
|
reversed the <code>matrix_range</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Matrix based range class<br>
|
|
template<class M><br>
|
|
class matrix_range:<br>
|
|
public matrix_expression<matrix_range<M> > {<br>
|
|
public: <br>
|
|
typedef const M const_matrix_type;<br>
|
|
typedef M matrix_type;<br>
|
|
typedef typename M::size_type size_type;<br>
|
|
typedef typename M::difference_type difference_type;<br>
|
|
typedef typename M::value_type value_type;<br>
|
|
typedef typename M::const_reference const_reference;<br>
|
|
typedef typename M::reference reference;<br>
|
|
typedef typename M::const_pointer const_pointer;<br>
|
|
typedef typename M::pointer pointer;<br>
|
|
typedef const matrix_const_reference<const matrix_range<matrix_type> > const_closure_type;<br>
|
|
typedef matrix_reference<matrix_range<matrix_type> > closure_type;<br>
|
|
typedef typename M::const_iterator1 const_iterator1_type;<br>
|
|
typedef typename M::iterator1 iterator1_type;<br>
|
|
typedef typename M::const_iterator2 const_iterator2_type;<br>
|
|
typedef typename M::iterator2 iterator2_type;<br>
|
|
typedef typename storage_restrict_traits<typename M::storage_category,<br>
|
|
dense_proxy_tag>::storage_category storage_category;<br>
|
|
typedef typename M::orientation_category orientation_category;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
matrix_range ();<br>
|
|
matrix_range (matrix_type &data, const range &r1, const range &r2);<br>
|
|
<br>
|
|
// Accessors<br>
|
|
size_type start1 () const;<br>
|
|
size_type size1 () const;<br>
|
|
size_type start2() const;<br>
|
|
size_type size2 () const;<br>
|
|
const_matrix_type &data () const;<br>
|
|
matrix_type &data ();<br>
|
|
<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i, size_type j) const;<br>
|
|
reference operator () (size_type i, size_type j);<br>
|
|
<br>
|
|
matrix_range<matrix_type> project (const range &r1, const range &r2) const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
matrix_range &operator = (const matrix_range &mr);<br>
|
|
matrix_range &assign_temporary (matrix_range &mr);<br>
|
|
template<class AE><br>
|
|
matrix_range &operator = (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_range &assign (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_range& operator += (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_range &plus_assign (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_range& operator -= (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_range &minus_assign (const matrix_expression<AE> &ae);<br>
|
|
template<class AT><br>
|
|
matrix_range& operator *= (const AT &at);<br>
|
|
template<class AT><br>
|
|
matrix_range& operator /= (const AT &at);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (matrix_range &mr);<br>
|
|
friend void swap (matrix_range &mr1, matrix_range &mr2);<br>
|
|
<br>
|
|
class const_iterator1;<br>
|
|
class iterator1;<br>
|
|
class const_iterator2;<br>
|
|
class iterator2;<br>
|
|
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br>
|
|
typedef reverse_iterator_base1<iterator1> reverse_iterator1;<br>
|
|
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br>
|
|
typedef reverse_iterator_base2<iterator2> reverse_iterator2;<br>
|
|
<br>
|
|
// Element lookup<br>
|
|
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br>
|
|
iterator1 find_first1 (int rank, size_type i, size_type j);<br>
|
|
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br>
|
|
iterator1 find_last1 (int rank, size_type i, size_type j);<br>
|
|
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br>
|
|
iterator2 find_first2 (int rank, size_type i, size_type j);<br>
|
|
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br>
|
|
iterator2 find_last2 (int rank, size_type i, size_type j);<br>
|
|
<br>
|
|
// Iterators simply are pointers.<br>
|
|
<br>
|
|
class const_iterator1:<br>
|
|
public container_const_reference<matrix_range>,<br>
|
|
public random_access_iterator_base<const_iterator1, value_type> {<br>
|
|
public:<br>
|
|
typedef typename const_iterator1_type::iterator_category iterator_category;<br>
|
|
typedef typename const_iterator1_type::difference_type difference_type;<br>
|
|
typedef typename const_iterator1_type::value_type value_type;<br>
|
|
typedef typename const_iterator1_type::reference reference;<br>
|
|
typedef typename const_iterator1_type::pointer pointer;<br>
|
|
typedef const_iterator2 dual_iterator_type;<br>
|
|
typedef const_reverse_iterator2 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator1 ();<br>
|
|
const_iterator1 (const matrix_range &mr, const const_iterator1_type &it);<br>
|
|
const_iterator1 (const iterator1 &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator1 &operator ++ ();<br>
|
|
const_iterator1 &operator -- ();<br>
|
|
const_iterator1 &operator += (difference_type n);<br>
|
|
const_iterator1 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator1 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
const_iterator2 begin () const;<br>
|
|
const_iterator2 end () const;<br>
|
|
const_reverse_iterator2 rbegin () const;<br>
|
|
const_reverse_iterator2 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator1 &operator = (const const_iterator1 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator1 &it) const;<br>
|
|
bool operator <(const const_iterator1 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator1 begin1 () const;<br>
|
|
const_iterator1 end1 () const;<br>
|
|
<br>
|
|
class iterator1:<br>
|
|
public container_reference<matrix_range>,<br>
|
|
public random_access_iterator_base<iterator1, value_type> {<br>
|
|
public:<br>
|
|
typedef typename iterator1_type::iterator_category iterator_category;<br>
|
|
typedef typename iterator1_type::difference_type difference_type;<br>
|
|
typedef typename iterator1_type::value_type value_type;<br>
|
|
typedef typename iterator1_type::reference reference;<br>
|
|
typedef typename iterator1_type::pointer pointer;<br>
|
|
typedef iterator2 dual_iterator_type;<br>
|
|
typedef reverse_iterator2 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator1 ();<br>
|
|
iterator1 (matrix_range &mr, const iterator1_type &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator1 &operator ++ ();<br>
|
|
iterator1 &operator -- ();<br>
|
|
iterator1 &operator += (difference_type n);<br>
|
|
iterator1 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator1 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
iterator2 begin () const;<br>
|
|
iterator2 end () const;<br>
|
|
reverse_iterator2 rbegin () const;<br>
|
|
reverse_iterator2 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator1 &operator = (const iterator1 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator1 &it) const;<br>
|
|
bool operator <(const iterator1 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator1 begin1 ();<br>
|
|
iterator1 end1 ();<br>
|
|
<br>
|
|
class const_iterator2:<br>
|
|
public container_const_reference<matrix_range>,<br>
|
|
public random_access_iterator_base<const_iterator2, value_type> {<br>
|
|
public:<br>
|
|
typedef typename const_iterator2_type::iterator_category iterator_category;<br>
|
|
typedef typename const_iterator2_type::difference_type difference_type;<br>
|
|
typedef typename const_iterator2_type::value_type value_type;<br>
|
|
typedef typename const_iterator2_type::reference reference;<br>
|
|
typedef typename const_iterator2_type::pointer pointer;<br>
|
|
typedef const_iterator1 dual_iterator_type;<br>
|
|
typedef const_reverse_iterator1 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator2 ();<br>
|
|
const_iterator2 (const matrix_range &mr, const const_iterator2_type &it);<br>
|
|
const_iterator2 (const iterator2 &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator2 &operator ++ ();<br>
|
|
const_iterator2 &operator -- ();<br>
|
|
const_iterator2 &operator += (difference_type n);<br>
|
|
const_iterator2 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator2 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
const_iterator1 begin () const;<br>
|
|
const_iterator1 end () const;<br>
|
|
const_reverse_iterator1 rbegin () const;<br>
|
|
const_reverse_iterator1 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator2 &operator = (const const_iterator2 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator2 &it) const;<br>
|
|
bool operator <(const const_iterator2 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator2 begin2 () const;<br>
|
|
const_iterator2 end2 () const;<br>
|
|
<br>
|
|
class iterator2:<br>
|
|
public container_reference<matrix_range>,<br>
|
|
public random_access_iterator_base<iterator2, value_type> {<br>
|
|
public:<br>
|
|
typedef typename iterator2_type::iterator_category iterator_category;<br>
|
|
typedef typename iterator2_type::difference_type difference_type;<br>
|
|
typedef typename iterator2_type::value_type value_type;<br>
|
|
typedef typename iterator2_type::reference reference;<br>
|
|
typedef typename iterator2_type::pointer pointer;<br>
|
|
typedef iterator1 dual_iterator_type;<br>
|
|
typedef reverse_iterator1 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator2 ();<br>
|
|
iterator2 (matrix_range &mr, const iterator2_type &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator2 &operator ++ ();<br>
|
|
iterator2 &operator -- ();<br>
|
|
iterator2 &operator += (difference_type n);<br>
|
|
iterator2 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator2 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
iterator1 begin () const;<br>
|
|
iterator1 end () const;<br>
|
|
reverse_iterator1 rbegin () const;<br>
|
|
reverse_iterator1 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator2 &operator = (const iterator2 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator2 &it) const;<br>
|
|
bool operator <(const iterator2 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator2 begin2 ();<br>
|
|
iterator2 end2 ();<br>
|
|
<br>
|
|
// Reverse iterators<br>
|
|
<br>
|
|
const_reverse_iterator1 rbegin1 () const;<br>
|
|
const_reverse_iterator1 rend1 () const;<br>
|
|
<br>
|
|
reverse_iterator1 rbegin1 ();<br>
|
|
reverse_iterator1 rend1 ();<br>
|
|
<br>
|
|
const_reverse_iterator2 rbegin2 () const;<br>
|
|
const_reverse_iterator2 rend2 () const;<br>
|
|
<br>
|
|
reverse_iterator2 rbegin2 ();<br>
|
|
reverse_iterator2 rend2 ();<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h3>Projections</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre>
|
|
<code>template<class M><br>
|
|
matrix_range<M> project (M &data, const range &r1, const range &r2);<br>
|
|
template<class M><br>
|
|
const matrix_range<const M> project (const M &data, const range &r1, const range &r2);<br>
|
|
template<class M><br>
|
|
matrix_range<M> project (const matrix_range<M> &data, const range &r1, const range &r2);</code>
|
|
</pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The free <code>project</code> functions support the construction
|
|
of matrix ranges.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<ul>
|
|
<li><code>M</code> is a model of <a href=
|
|
"expression.htm#matrix_expression">Matrix Expression</a> .</li>
|
|
</ul>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<ul type="Disc">
|
|
<li><code>r1.start () + r1.size () <= data.size1 ()</code></li>
|
|
|
|
<li><code>r2.start () + r2.size () <= data.size2 ()</code></li>
|
|
</ul>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the ranges.</p>
|
|
|
|
<h4>Examples</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i)<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j)<br>
|
|
project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j;<br>
|
|
std::cout << project (m, range (0, 3), range (0, 3)) << std::endl;<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h2><a name="matrix_slice"></a> Matrix Slice</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_slice<M></code> allows
|
|
addressing a sliced sub matrix of a matrix.</p>
|
|
|
|
<h4>Example</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3));<br>
|
|
for (unsigned i = 0; i < ms.size1 (); ++ i)<br>
|
|
for (unsigned j = 0; j < ms.size2 (); ++ j)<br>
|
|
ms (i, j) = 3 * i + j;<br>
|
|
std::cout << ms << std::endl;<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Description</th>
|
|
<th>Default</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>M</code> </td>
|
|
<td>The type of matrix referenced.</td>
|
|
<td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p><a href="expression.htm#matrix_expression">Matrix Expression</a>
|
|
.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None, except for those imposed by the requirements of <a href=
|
|
"expression.htm#matrix_expression">Matrix Expression</a> .</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p><code>matrix_expression<matrix_slice<M> ></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_slice (matrix_type &data,<br>
|
|
const slice &s1, const slice &s2)</code></td>
|
|
<td>Constructs a sub matrix.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size1 () const</code></td>
|
|
<td>Returns the number of rows.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>size_type size2 () const</code></td>
|
|
<td>Returns the number of columns.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reference operator () (size_type i, size_type j)
|
|
const</code></td>
|
|
<td>Returns the value of the <code>j</code>-th element in the
|
|
<code>i</code>-th row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reference operator () (size_type i, size_type
|
|
j)</code></td>
|
|
<td>Returns a reference of the <code>j</code>-th element in the
|
|
<code>i</code>-th row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_slice &operator = (const matrix_slice
|
|
&ms)</code></td>
|
|
<td>The assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>matrix_slice &assign_temporary (matrix_slice
|
|
&ms)</code></td>
|
|
<td>Assigns a temporary. May change the matrix slice
|
|
<code>ms</code> .</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_slice &operator = (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>The extended assignment operator.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_slice &assign (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Assigns a matrix expression to the sub matrix. Left and right
|
|
hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_slice &operator += (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Adds the matrix expression to
|
|
the sub matrix.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_slice &plus_assign (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Adds a matrix expression to the sub matrix. Left and right hand
|
|
side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_slice &operator -= (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>A computed assignment operator. Subtracts the matrix expression
|
|
from the sub matrix.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AE><br>
|
|
matrix_slice &minus_assign (const matrix_expression<AE>
|
|
&ae)</code></td>
|
|
<td>Subtracts a matrix expression from the sub matrix. Left and
|
|
right hand side of the assignment should be independent.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_slice &operator *= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub matrix with
|
|
a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>template<class AT><br>
|
|
matrix_slice &operator /= (const AT &at)</code></td>
|
|
<td>A computed assignment operator. Multiplies the sub matrix
|
|
through a scalar.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>void swap (matrix_slice &ms)</code></td>
|
|
<td>Swaps the contents of the sub matrices.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to the
|
|
beginning of the <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to the end of
|
|
the <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator1 begin1 ()</code> </td>
|
|
<td>Returns a <code>iterator1</code> pointing to the beginning of
|
|
the <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator1 end1 ()</code> </td>
|
|
<td>Returns a <code>iterator1</code> pointing to the end of the
|
|
<code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to the
|
|
beginning of the <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to the end of
|
|
the <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator2 begin2 ()</code> </td>
|
|
<td>Returns a <code>iterator2</code> pointing to the beginning of
|
|
the <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>iterator2 end2 ()</code> </td>
|
|
<td>Returns a <code>iterator2</code> pointing to the end of the
|
|
<code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator1 rbegin1 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
|
|
beginning of the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator1 rend1 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator1</code> pointing to the
|
|
end of the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator1 rbegin1 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator1</code> pointing to the
|
|
beginning of the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator1 rend1 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator1</code> pointing to the end of
|
|
the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator2 rbegin2 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
|
|
beginning of the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>const_reverse_iterator2 rend2 () const</code></td>
|
|
<td>Returns a <code>const_reverse_iterator2</code> pointing to the
|
|
end of the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator2 rbegin2 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator2</code> pointing to the
|
|
beginning of the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td><code>reverse_iterator2 rend2 ()</code> </td>
|
|
<td>Returns a <code>reverse_iterator2</code> pointing to the end of
|
|
the reversed <code>matrix_slice</code>.</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre>
|
|
<code>// Matrix based slice class<br>
|
|
template<class M><br>
|
|
class matrix_slice:<br>
|
|
public matrix_expression<matrix_slice<M> > {<br>
|
|
public: <br>
|
|
typedef const M const_matrix_type;<br>
|
|
typedef M matrix_type;<br>
|
|
typedef typename M::size_type size_type;<br>
|
|
typedef typename M::difference_type difference_type;<br>
|
|
typedef typename M::value_type value_type;<br>
|
|
typedef typename M::const_reference const_reference;<br>
|
|
typedef typename M::reference reference;<br>
|
|
typedef typename M::const_pointer const_pointer;<br>
|
|
typedef typename M::pointer pointer;<br>
|
|
typedef const matrix_const_reference<const matrix_slice<matrix_type> > const_closure_type;<br>
|
|
typedef matrix_reference<matrix_slice<matrix_type> > closure_type;<br>
|
|
typedef slice::const_iterator const_iterator1_type;<br>
|
|
typedef slice::const_iterator iterator1_type;<br>
|
|
typedef slice::const_iterator const_iterator2_type;<br>
|
|
typedef slice::const_iterator iterator2_type;<br>
|
|
typedef typename storage_restrict_traits<typename M::storage_category,<br>
|
|
dense_proxy_tag>::storage_category storage_category;<br>
|
|
typedef typename M::orientation_category orientation_category;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
matrix_slice ();<br>
|
|
matrix_slice (matrix_type &data, const slice &s1, const slice &s2);<br>
|
|
<br>
|
|
// Accessors<br>
|
|
size_type size1 () const;<br>
|
|
size_type size2 () const;<br>
|
|
const_matrix_type &data () const;<br>
|
|
matrix_type &data ();<br>
|
|
<br>
|
|
// Element access<br>
|
|
const_reference operator () (size_type i, size_type j) const;<br>
|
|
reference operator () (size_type i, size_type j);<br>
|
|
<br>
|
|
matrix_slice<matrix_type> project (const range &r1, const range &r2) const;<br>
|
|
matrix_slice<matrix_type> project (const slice &s1, const slice &s2) const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
matrix_slice &operator = (const matrix_slice &ms);<br>
|
|
matrix_slice &assign_temporary (matrix_slice &ms);<br>
|
|
template<class AE><br>
|
|
matrix_slice &operator = (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_slice &assign (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_slice& operator += (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_slice &plus_assign (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_slice& operator -= (const matrix_expression<AE> &ae);<br>
|
|
template<class AE><br>
|
|
matrix_slice &minus_assign (const matrix_expression<AE> &ae);<br>
|
|
template<class AT><br>
|
|
matrix_slice& operator *= (const AT &at);<br>
|
|
template<class AT><br>
|
|
matrix_slice& operator /= (const AT &at);<br>
|
|
<br>
|
|
// Swapping<br>
|
|
void swap (matrix_slice &ms);<br>
|
|
friend void swap (matrix_slice &ms1, matrix_slice &ms2);<br>
|
|
<br>
|
|
class const_iterator1;<br>
|
|
class iterator1;<br>
|
|
class const_iterator2;<br>
|
|
class iterator2;<br>
|
|
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br>
|
|
typedef reverse_iterator_base1<iterator1> reverse_iterator1;<br>
|
|
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br>
|
|
typedef reverse_iterator_base2<iterator2> reverse_iterator2;<br>
|
|
<br>
|
|
// Element lookup<br>
|
|
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br>
|
|
iterator1 find_first1 (int rank, size_type i, size_type j);<br>
|
|
const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br>
|
|
iterator1 find_last1 (int rank, size_type i, size_type j);<br>
|
|
const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br>
|
|
iterator2 find_first2 (int rank, size_type i, size_type j);<br>
|
|
const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br>
|
|
iterator2 find_last2 (int rank, size_type i, size_type j);<br>
|
|
<br>
|
|
// Iterators simply are indices.<br>
|
|
<br>
|
|
class const_iterator1:<br>
|
|
public container_const_reference<matrix_slice>,<br>
|
|
public random_access_iterator_base<const_iterator1, value_type> {<br>
|
|
public:<br>
|
|
typedef typename M::const_iterator1::iterator_category iterator_category;<br>
|
|
typedef typename M::const_iterator1::difference_type difference_type;<br>
|
|
typedef typename M::const_iterator1::value_type value_type;<br>
|
|
typedef typename M::const_iterator1::reference reference;<br>
|
|
typedef typename M::const_iterator1::pointer pointer;<br>
|
|
typedef const_iterator2 dual_iterator_type;<br>
|
|
typedef const_reverse_iterator2 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator1 ();<br>
|
|
const_iterator1 (const matrix_slice &ms, const const_iterator1_type &it1, const const_iterator2_type &it2);<br>
|
|
const_iterator1 (const iterator1 &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator1 &operator ++ ();<br>
|
|
const_iterator1 &operator -- ();<br>
|
|
const_iterator1 &operator += (difference_type n);<br>
|
|
const_iterator1 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator1 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
const_iterator2 begin () const;<br>
|
|
const_iterator2 end () const;<br>
|
|
const_reverse_iterator2 rbegin () const;<br>
|
|
const_reverse_iterator2 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator1 &operator = (const const_iterator1 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator1 &it) const;<br>
|
|
bool operator <(const const_iterator1 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator1 begin1 () const;<br>
|
|
const_iterator1 end1 () const;<br>
|
|
<br>
|
|
class iterator1:<br>
|
|
public container_reference<matrix_slice>,<br>
|
|
public random_access_iterator_base<iterator1, value_type> {<br>
|
|
public:<br>
|
|
typedef typename M::iterator1::iterator_category iterator_category;<br>
|
|
typedef typename M::iterator1::difference_type difference_type;<br>
|
|
typedef typename M::iterator1::value_type value_type;<br>
|
|
typedef typename M::iterator1::reference reference;<br>
|
|
typedef typename M::iterator1::pointer pointer;<br>
|
|
typedef iterator2 dual_iterator_type;<br>
|
|
typedef reverse_iterator2 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator1 ();<br>
|
|
iterator1 (matrix_slice &ms, const iterator1_type &it1, const iterator2_type &it2);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator1 &operator ++ ();<br>
|
|
iterator1 &operator -- ();<br>
|
|
iterator1 &operator += (difference_type n);<br>
|
|
iterator1 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator1 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
iterator2 begin () const;<br>
|
|
iterator2 end () const;<br>
|
|
reverse_iterator2 rbegin () const;<br>
|
|
reverse_iterator2 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator1 &operator = (const iterator1 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator1 &it) const;<br>
|
|
bool operator <(const iterator1 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator1 begin1 ();<br>
|
|
iterator1 end1 ();<br>
|
|
<br>
|
|
class const_iterator2:<br>
|
|
public container_const_reference<matrix_slice>,<br>
|
|
public random_access_iterator_base<const_iterator2, value_type> {<br>
|
|
public:<br>
|
|
typedef typename M::const_iterator2::iterator_category iterator_category;<br>
|
|
typedef typename M::const_iterator2::difference_type difference_type;<br>
|
|
typedef typename M::const_iterator2::value_type value_type;<br>
|
|
typedef typename M::const_iterator2::reference reference;<br>
|
|
typedef typename M::const_iterator2::pointer pointer;<br>
|
|
typedef const_iterator1 dual_iterator_type;<br>
|
|
typedef const_reverse_iterator1 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
const_iterator2 ();<br>
|
|
const_iterator2 (const matrix_slice &ms, const const_iterator1_type &it1, const const_iterator2_type &it2);<br>
|
|
const_iterator2 (const iterator2 &it);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
const_iterator2 &operator ++ ();<br>
|
|
const_iterator2 &operator -- ();<br>
|
|
const_iterator2 &operator += (difference_type n);<br>
|
|
const_iterator2 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const const_iterator2 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
const_iterator1 begin () const;<br>
|
|
const_iterator1 end () const;<br>
|
|
const_reverse_iterator1 rbegin () const;<br>
|
|
const_reverse_iterator1 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
const_iterator2 &operator = (const const_iterator2 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const const_iterator2 &it) const;<br>
|
|
bool operator <(const const_iterator2 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
const_iterator2 begin2 () const;<br>
|
|
const_iterator2 end2 () const;<br>
|
|
<br>
|
|
class iterator2:<br>
|
|
public container_reference<matrix_slice>,<br>
|
|
public random_access_iterator_base<iterator2, value_type> {<br>
|
|
public:<br>
|
|
typedef typename M::iterator2::iterator_category iterator_category;<br>
|
|
typedef typename M::iterator2::difference_type difference_type;<br>
|
|
typedef typename M::iterator2::value_type value_type;<br>
|
|
typedef typename M::iterator2::reference reference;<br>
|
|
typedef typename M::iterator2::pointer pointer;<br>
|
|
typedef iterator1 dual_iterator_type;<br>
|
|
typedef reverse_iterator1 dual_reverse_iterator_type;<br>
|
|
<br>
|
|
// Construction and destruction<br>
|
|
iterator2 ();<br>
|
|
iterator2 (matrix_slice &ms, const iterator1_type &it1, const iterator2_type &it2);<br>
|
|
<br>
|
|
// Arithmetic<br>
|
|
iterator2 &operator ++ ();<br>
|
|
iterator2 &operator -- ();<br>
|
|
iterator2 &operator += (difference_type n);<br>
|
|
iterator2 &operator -= (difference_type n);<br>
|
|
difference_type operator - (const iterator2 &it) const;<br>
|
|
<br>
|
|
// Dereference<br>
|
|
reference operator * () const;<br>
|
|
<br>
|
|
iterator1 begin () const;<br>
|
|
iterator1 end () const;<br>
|
|
reverse_iterator1 rbegin () const;<br>
|
|
reverse_iterator1 rend () const;<br>
|
|
<br>
|
|
// Indices<br>
|
|
size_type index1 () const;<br>
|
|
size_type index2 () const;<br>
|
|
<br>
|
|
// Assignment<br>
|
|
iterator2 &operator = (const iterator2 &it);<br>
|
|
<br>
|
|
// Comparison<br>
|
|
bool operator == (const iterator2 &it) const;<br>
|
|
bool operator <(const iterator2 &it) const;<br>
|
|
};<br>
|
|
<br>
|
|
iterator2 begin2 ();<br>
|
|
iterator2 end2 ();<br>
|
|
<br>
|
|
// Reverse iterators<br>
|
|
<br>
|
|
const_reverse_iterator1 rbegin1 () const;<br>
|
|
const_reverse_iterator1 rend1 () const;<br>
|
|
<br>
|
|
reverse_iterator1 rbegin1 ();<br>
|
|
reverse_iterator1 rend1 ();<br>
|
|
<br>
|
|
const_reverse_iterator2 rbegin2 () const;<br>
|
|
const_reverse_iterator2 rend2 () const;<br>
|
|
<br>
|
|
reverse_iterator2 rbegin2 ();<br>
|
|
reverse_iterator2 rend2 ();<br>
|
|
};</code>
|
|
</pre>
|
|
|
|
<h3>Projections</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre>
|
|
<code>template<class M><br>
|
|
matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2);<br>
|
|
template<class M><br>
|
|
matrix_slice<M> project (M &data, const slice &s1, const slice &s2);<br>
|
|
template<class M><br>
|
|
const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2);<br>
|
|
template<class M><br>
|
|
matrix_slice<M> project (const matrix_slice<M> &data, const slice &s1, const slice &s2);</code>
|
|
</pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The free <code>project</code> functions support the construction
|
|
of matrix slices.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_proxy.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<ul>
|
|
<li><code>M</code> is a model of <a href=
|
|
"expression.htm#matrix_expression">Matrix Expression</a> .</li>
|
|
</ul>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<ul type="Disc">
|
|
<li><code>s1.start () + s1.stride () * s1.size () <= data.size1
|
|
()</code></li>
|
|
|
|
<li><code>s2.start () + s2.stride () * s2.size () <= data.size2
|
|
()</code></li>
|
|
</ul>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the slices.</p>
|
|
|
|
<h4>Examples</h4>
|
|
|
|
<pre>
|
|
#include <boost/numeric/ublas/matrix.hpp><br>
|
|
#include <boost/numeric/ublas/io.hpp><br>
|
|
<br>
|
|
int main () {<br>
|
|
using namespace boost::numeric::ublas;<br>
|
|
matrix<double> m (3, 3);<br>
|
|
for (unsigned i = 0; i < m.size1 (); ++ i)<br>
|
|
for (unsigned j = 0; j < m.size2 (); ++ j)<br>
|
|
project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j;<br>
|
|
std::cout << project (m, slice (0, 1, 3), slice (0, 1, 3)) << std::endl;<br>
|
|
}<br>
|
|
</pre>
|
|
|
|
<hr>
|
|
<p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br>
|
|
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.</p>
|
|
|
|
<p>Last revised: 1/15/2003</p>
|
|
</body>
|
|
</html>
|
|
|