<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" /> <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> <link rel="stylesheet" href="../../../../boost.css" type="text/css"/> <link rel="stylesheet" href="ublas.css" type="text/css" /> <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script> <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script> <title>Matrix Proxies</title> </head> <body> <h1><img src="../../../../boost.png" align="middle" />Matrix Proxies</h1> <div class="toc" id="toc"></div> <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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) { matrix_row<matrix<double> > mr (m, i); for (unsigned j = 0; j < mr.size (); ++ j) mr (j) = 3 * i + j; std::cout << mr << std::endl; } } </pre> <h4>Definition</h4> <p>Defined in the header matrix_proxy.hpp.</p> <h4>Template parameters</h4> <table border="1" summary="parameters"> <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_concept.htm#vector_expression">Vector Expression</a> .</p> <p>If the specified row falls outside that of the row index range of the matrix, then the <code>matrix_row</code> is not a well formed Vector Expression. That is, access to an element which is outside of the matrix is <i>undefined</i>.</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "expression_concept.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" summary="members"> <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> <h3>Projections</h3> <h4>Description</h4> <p>The free <code>row</code> functions support the construction of matrix rows.</p> <h4>Prototypes</h4> <pre><code> template<class M> matrix_row<M> row (M &data, std::size_t i); template<class M> const matrix_row<const M> row (const M &data, std::size_t i); </code></pre> <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_concept.htm#matrix_expression">Matrix Expression</a> .</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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) { for (unsigned j = 0; j < m.size2 (); ++ j) row (m, i) (j) = 3 * i + j; std::cout << row (m, i) << std::endl; } } </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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned j = 0; j < m.size2 (); ++ j) { matrix_column<matrix<double> > mc (m, j); for (unsigned i = 0; i < mc.size (); ++ i) mc (i) = 3 * i + j; std::cout << mc << std::endl; } } </pre> <h4>Definition</h4> <p>Defined in the header matrix_proxy.hpp.</p> <h4>Template parameters</h4> <table border="1" summary="parameters"> <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_concept.htm#vector_expression">Vector Expression</a> .</p> <p>If the specified column falls outside that of the column index range of the matrix, then the <code>matrix_column</code> is not a well formed Vector Expression. That is, access to an element which is outside of the matrix is <i>undefined</i>.</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "expression_concept.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" summary="members"> <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> <h3>Projections</h3> <h4>Description</h4> <p>The free <code>column</code> functions support the construction of matrix columns.</p> <h4>Prototypes</h4> <pre><code> template<class M> matrix_column<M> column (M &data, std::size_t j); template<class M> const matrix_column<const M> column (const M &data, std::size_t j); </code></pre> <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_concept.htm#matrix_expression">Matrix Expression</a> .</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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned j = 0; j < m.size2 (); ++ j) { for (unsigned i = 0; i < m.size1 (); ++ i) column (m, j) (i) = 3 * i + j; std::cout << column (m, j) << std::endl; } } </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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; matrix_vector_range<matrix<double> > mvr (m, range (0, 3), range (0, 3)); std::cout << mvr << std::endl; } </pre> <h4>Definition</h4> <p>Defined in the header matrix_proxy.hpp.</p> <h4>Template parameters</h4> <table border="1" summary="parameters"> <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_concept.htm#vector_expression">Vector Expression</a> .</p> <p>If the specified ranges fall outside that of the index range of the matrix, then the <code>matrix_vector_range</code> is not a well formed Vector Expression. That is, access to an element which is outside of the matrix is <i>undefined</i>.</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "expression_concept.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" summary="members"> <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> <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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; matrix_vector_slice<matrix<double> > mvs (m, slice (0, 1, 3), slice (0, 1, 3)); std::cout << mvs << std::endl; } </pre> <h4>Definition</h4> <p>Defined in the header matrix_proxy.hpp.</p> <h4>Template parameters</h4> <table border="1" summary="parameters"> <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_concept.htm#vector_expression">Vector Expression</a> .</p> <p>If the specified slices fall outside that of the index range of the matrix, then the <code>matrix_vector_slice</code> is not a well formed Vector Expression. That is, access to an element which is outside of the matrix is <i>undefined</i>.</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "expression_concept.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" summary="members"> <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> <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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); matrix_range<matrix<double> > mr (m, range (0, 3), range (0, 3)); for (unsigned i = 0; i < mr.size1 (); ++ i) for (unsigned j = 0; j < mr.size2 (); ++ j) mr (i, j) = 3 * i + j; std::cout << mr << std::endl; } </pre> <h4>Definition</h4> <p>Defined in the header matrix_proxy.hpp.</p> <h4>Template parameters</h4> <table border="1" summary="parameters"> <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_concept.htm#matrix_expression">Matrix Expression</a> .</p> <p>If the specified ranges fall outside that of the index range of the matrix, then the <code>matrix_range</code> is not a well formed Matrix Expression. That is, access to an element which is outside of the matrix is <i>undefined</i>.</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "expression_concept.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" summary="members"> <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> <h3>Simple Projections</h3> <h4>Description</h4> <p>The free <code>subrange</code> functions support the construction of matrix ranges.</p> <h4>Prototypes</h4> <pre><code> template<class M> matrix_range<M> subrange (M &data, M::size_type start1, M::size_type stop1, M::size_type start2, M::size_type, stop2); template<class M> const matrix_range<const M> subrange (const M &data, M::size_type start1, M::size_type stop1, M::size_type start2, M::size_type, stop2); </code></pre> <h3>Generic Projections</h3> <h4>Description</h4> <p>The free <code>project</code> functions support the construction of matrix ranges. Existing <code>matrix_range</code>'s can be composed with further ranges. The resulting ranges are computed using this existing ranges' <code>compose</code> function.</p> <h4>Prototypes</h4> <pre><code> template<class M> matrix_range<M> project (M &data, const range &r1, const range &r2); template<class M> const matrix_range<const M> project (const M &data, const range &r1, const range &r2); template<class M> matrix_range<M> project (matrix_range<M> &data, const range &r1, const range &r2); template<class M> const matrix_range<M> project (const matrix_range<M> &data, const range &r1, const range &r2); </code></pre> <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_concept.htm#matrix_expression">Matrix Expression</a> .</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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) for (unsigned j = 0; j < m.size2 (); ++ j) project (m, range (0, 3), range (0, 3)) (i, j) = 3 * i + j; std::cout << project (m, range (0, 3), range (0, 3)) << std::endl; } </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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); matrix_slice<matrix<double> > ms (m, slice (0, 1, 3), slice (0, 1, 3)); for (unsigned i = 0; i < ms.size1 (); ++ i) for (unsigned j = 0; j < ms.size2 (); ++ j) ms (i, j) = 3 * i + j; std::cout << ms << std::endl; } </pre> <h4>Definition</h4> <p>Defined in the header matrix_proxy.hpp.</p> <h4>Template parameters</h4> <table border="1" summary="parameters"> <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_concept.htm#matrix_expression">Matrix Expression</a> .</p> <p>If the specified slices fall outside that of the index range of the matrix, then the <code>matrix_slice</code> is not a well formed Matrix Expression. That is, access to an element which is outside of the matrix is <i>undefined</i>.</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "expression_concept.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" summary="members"> <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> <h3>Simple Projections</h3> <h4>Description</h4> <p>The free <code>subslice</code> functions support the construction of matrix slices.</p> <h4>Prototypes</h4> <pre><code> template<class M> matrix_slice<M> subslice (M &data, M::size_type start1, M::difference_type stride1, M::size_type size1, M::size_type start2, M::difference_type stride2, M::size_type size2); template<class M> const matrix_slice<const M> subslice (const M &data, M::size_type start1, M::difference_type stride1, M::size_type size1, M::size_type start2, M::difference_type stride2, M::size_type size2); </code></pre> <h3>Generic Projections</h3> <h4>Description</h4> <p>The free <code>project</code> functions support the construction of matrix slices. Existing <code>matrix_slice</code>'s can be composed with further ranges or slices. The resulting slices are computed using this existing slices' <code>compose</code> function.</p> <h4>Prototypes</h4> <pre><code> template<class M> matrix_slice<M> project (M &data, const slice &s1, const slice &s2); template<class M> const matrix_slice<const M> project (const M &data, const slice &s1, const slice &s2); template<class M> matrix_slice<M> project (matrix_slice<M> &data, const range &r1, const range &r2); template<class M> const matrix_slice<M> project (const matrix_slice<M> &data, const range &r1, const range &r2); template<class M> matrix_slice<M> project (matrix_slice<M> &data, const slice &s1, const slice &s2); template<class M> const matrix_slice<M> project (const matrix_slice<M> &data, const slice &s1, const slice &s2); </code></pre> <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_concept.htm#matrix_expression">Matrix Expression</a> .</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> #include <boost/numeric/ublas/matrix_proxy.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) for (unsigned j = 0; j < m.size2 (); ++ j) project (m, slice (0, 1, 3), slice (0, 1, 3)) (i, j) = 3 * i + j; std::cout << project (m, slice (0, 1, 3), slice (0, 1, 3)) << std::endl; } </pre> <hr /> <p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br /> Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt"> http://www.boost.org/LICENSE_1_0.txt </a>). </p> <script type="text/javascript"> (function($) { $('#toc').toc(); })(jQuery); </script> </body> </html>