mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-09 11:32:19 +00:00
1415 lines
115 KiB
HTML
1415 lines
115 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
|
|
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
|
<title>Matrix Expressions</title>
|
|
</head>
|
|
<body bgcolor="#ffffff">
|
|
|
|
<h1><img src="c++boost.gif" alt="c++boost.gif" align="Center">
|
|
Matrix Expressions</h1>
|
|
|
|
<h2><a name="matrix_expression"></a>
|
|
Matrix Expression</h2>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_expression<E> </code>forms the base
|
|
for all static derived matrix expression classes including class <code> matrix</code>
|
|
itself.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E</code> </td>
|
|
<td>The type of the matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Model of</h4>
|
|
|
|
<p>None. </p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<p>None.</p>
|
|
|
|
<h4>Public base classes</h4>
|
|
|
|
<p>None.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const expression_type &operator () () const</code></td>
|
|
<td>Returns a <code>const </code>reference of the expression.
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>expression_type &operator () ()</code></td>
|
|
<td>Returns a reference of the expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> // Base class for the Barton Nackman trick<br> template<class E><br> struct matrix_expression {<br> typedef E expression_type;<br> typedef matrix_tag type_category;<br><br> // This class could define an common interface for all<br> // statically derived expression type classes.<br> // Due to a compiler deficiency - one can not reference class typedefs of E<br> // on MSVC 6.0 (error C2027) - we only implement the casts.<br><br> const expression_type &operator () () const;<br> expression_type &operator () ();<br> };</code></pre>
|
|
|
|
<h2><a name="matrix_references"></a>
|
|
Matrix References</h2>
|
|
|
|
<h3>Constant Reference</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_const_reference<E> </code>contains
|
|
a constant reference to a matrix expression.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E</code> </td>
|
|
<td>The type of the matrix expression. </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_const_reference<E> ></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_const_reference (const expression_type
|
|
&e)</code> </td>
|
|
<td>Constructs a constant reference of the expression.</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>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the end of the expression. </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 expression. </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 expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<p>Interface </p>
|
|
|
|
<pre><code> template<class E><br> class matrix_const_reference:<br> public matrix_expression<matrix_const_reference<E> > {<br> public:<br> typedef E expression_type;<br> typedef typename E::size_type size_type;<br> typedef typename E::difference_type difference_type;<br> typedef typename E::value_type value_type;<br> typedef typename E::const_reference const_reference;<br> typedef const_reference reference;<br> typedef typename E::const_pointer const_pointer;<br> typedef const_pointer pointer;<br> typedef typename E::orientation_category orientation_category;<br> typedef typename E::const_iterator1 const_iterator1_type;<br> typedef typename E::const_iterator2 const_iterator2_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_const_reference ();<br> matrix_const_reference (const expression_type &e);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression_type &expression () const;<br><br> // Element access<br> const_reference operator () (size_type i, size_type j) const;<br><br> typedef const_iterator1_type const_iterator1;<br> typedef const_iterator1 iterator1;<br> typedef const_iterator2_type const_iterator2;<br> typedef const_iterator2 iterator2;<br><br> // Element lookup<br> const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators are the iterators of the referenced expression.<br><br> const_iterator1 begin1 () const;<br> const_iterator1 end1 () const;<br><br> const_iterator2 begin2 () const;<br> const_iterator2 end2 () const;<br><br> // Reverse iterators<br><br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br> };</code></pre>
|
|
|
|
<h3>Reference</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_reference<E> </code>contains a reference
|
|
to a matrix expression.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E</code> </td>
|
|
<td>The type of the matrix expression. </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_reference<E> ></code></p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_reference (expression_type &e)</code>
|
|
</td>
|
|
<td>Constructs a constant reference of the expression.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>void resize (size_type size1, size2)</code></td>
|
|
<td>Resizes the expression to hold at most <code>size1 </code>rows
|
|
of <code>size2 </code>elements. </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>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>iterator1 begin1 () </code></td>
|
|
<td>Returns a <code>iterator1</code> pointing to the beginning
|
|
of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>iterator1 end1 () </code></td>
|
|
<td>Returns a <code>iterator1</code> pointing to the end
|
|
of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>iterator2 begin2 () </code></td>
|
|
<td>Returns a <code>iterator2</code> pointing to the beginning
|
|
of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>iterator2 end2 () </code></td>
|
|
<td>Returns a <code>iterator2</code> pointing to the end
|
|
of the expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>reverse_iterator1 rbegin1 () </code></td>
|
|
<td>Returns a <code>reverse_iterator1</code> pointing to
|
|
the beginning of the reversed expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>reverse_iterator1 rend1 () </code></td>
|
|
<td>Returns a <code>reverse_iterator1</code> pointing to
|
|
the end of the reversed expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>reverse_iterator2 rbegin2 () </code></td>
|
|
<td>Returns a <code>reverse_iterator2</code> pointing to
|
|
the beginning of the reversed expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>reverse_iterator2 rend2 () </code></td>
|
|
<td>Returns a <code>reverse_iterator2</code> pointing to
|
|
the end of the reversed expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> template<class E><br> class matrix_reference:<br> public matrix_expression<matrix_reference<E> > {<br> public:<br> typedef E expression_type;<br> typedef typename E::size_type size_type;<br> typedef typename E::difference_type difference_type;<br> typedef typename E::value_type value_type;<br> typedef typename E::const_reference const_reference;<br> typedef typename E::reference reference;<br> typedef typename E::const_pointer const_pointer;<br> typedef typename E::pointer pointer;<br> typedef typename E::orientation_category orientation_category;<br> typedef typename E::const_iterator1 const_iterator1_type;<br> typedef typename E::iterator1 iterator1_type;<br> typedef typename E::const_iterator2 const_iterator2_type;<br> typedef typename E::iterator2 iterator2_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_reference ();<br> matrix_reference (expression_type &e);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression_type &expression () const;<br> expression_type &expression ();<br><br> // Resizing<br> void resize (size_type size1, size_type size2);<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> typedef const_iterator1_type const_iterator1;<br> typedef iterator1_type iterator1;<br> typedef const_iterator2_type const_iterator2;<br> typedef iterator2_type 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 are the iterators of the referenced expression.<br><br> const_iterator1 begin1 () const;<br> const_iterator1 end1 () const;<br><br> iterator1 begin1 ();<br> iterator1 end1 ();<br><br> const_iterator2 begin2 () const;<br> const_iterator2 end2 () const;<br><br> iterator2 begin2 ();<br> iterator2 end2 ();<br><br> // Reverse iterators<br><br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> typedef reverse_iterator_base1<iterator1> reverse_iterator1;<br><br> reverse_iterator1 rbegin1 ();<br> reverse_iterator1 rend1 ();<br><br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br><br> typedef reverse_iterator_base2<iterator2> reverse_iterator2;<br><br> reverse_iterator2 rbegin2 ();<br> reverse_iterator2 rend2 ();<br> };</code></pre>
|
|
|
|
<h2><a name="matrix_operations"></a>
|
|
Matrix Operations</h2>
|
|
|
|
<h3>Unary Operation Description</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated classes <code>matrix_unary1<E, F> </code>and <code>
|
|
matrix_unary2<E, F> </code>describe unary matrix operations.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E</code> </td>
|
|
<td>The type of the matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>F</code></td>
|
|
<td>The type of the operation.</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_unary1<E, F> > </code>and<code>
|
|
matrix_expression<matrix_unary2<E, F> > </code>resp.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_unary1 (const expression_type &e)</code>
|
|
</td>
|
|
<td>Constructs a description of the expression.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_unary2 (const expression_type &e)</code></td>
|
|
<td>Constructs a description of the expression.</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>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the end of the expression. </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 expression. </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 expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> template<class E, class F><br> class matrix_unary1:<br> public matrix_expression<matrix_unary1<E, F> > {<br> public:<br> typedef E expression_type;<br> typedef F functor_type;<br> typedef typename E::size_type size_type;<br> typedef typename E::difference_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_unary1<E, F> const_closure_type;<br> typedef typename E::orientation_category orientation_category;<br> typedef typename E::const_iterator1 const_iterator1_type;<br> typedef typename E::const_iterator2 const_iterator2_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_unary1 ();<br> matrix_unary1 (const expression_type &e);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression_type &expression () const;<br><br> // Element access<br> const_reference operator () (size_type i, size_type j) const;<br><br> class const_iterator1;<br> typedef const_iterator1 iterator1;<br> class const_iterator2;<br> typedef const_iterator2 iterator2;<br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> // Element lookup<br> const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators enhance the iterators of the referenced expression<br> // with the unary functor.<br><br> class const_iterator1:<br> public container_const_reference<matrix_unary1>,<br> public random_access_iterator_base<const_iterator1, value_type> {<br> public:<br> typedef typename E::const_iterator1::iterator_category iterator_category;<br> typedef typename matrix_unary1::difference_type difference_type;<br> typedef typename matrix_unary1::value_type value_type;<br> typedef typename matrix_unary1::const_reference reference;<br> typedef typename matrix_unary1::const_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_unary1 &mu, const const_iterator1_type &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 const_iterator2:<br> public container_const_reference<matrix_unary1>,<br> public random_access_iterator_base<const_iterator2, value_type> {<br> public:<br> typedef typename E::const_iterator2::iterator_category iterator_category;<br> typedef typename matrix_unary1::difference_type difference_type;<br> typedef typename matrix_unary1::value_type value_type;<br> typedef typename matrix_unary1::const_reference reference;<br> typedef typename matrix_unary1::const_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_unary1 &mu, const const_iterator2_type &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> // Reverse iterators<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br> };<br><br> template<class E, class F><br> class matrix_unary2:<br> public matrix_expression<matrix_unary2<E, F> > {<br> public:<br> typedef E expression_type;<br> typedef F functor_type;<br> typedef typename E::size_type size_type;<br> typedef typename E::difference_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_unary2<E, F> const_closure_type;<br> typedef typename E::orientation_category orientation_category;<br> typedef typename E::const_iterator1 const_iterator2_type;<br> typedef typename E::const_iterator2 const_iterator1_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_unary2 ();<br> matrix_unary2 (const expression_type &e);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression_type &expression () const;<br><br> // Element access<br> const_reference operator () (size_type i, size_type j) const;<br><br> class const_iterator1;<br> typedef const_iterator1 iterator1;<br> class const_iterator2;<br> typedef const_iterator2 iterator2;<br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> // Element lookup<br> const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators enhance the iterators of the referenced expression<br> // with the unary functor.<br><br> class const_iterator1:<br> public container_const_reference<matrix_unary2>,<br> public random_access_iterator_base<const_iterator1, value_type> {<br> public:<br> typedef typename E::const_iterator2::iterator_category iterator_category;<br> typedef typename matrix_unary2::difference_type difference_type;<br> typedef typename matrix_unary2::value_type value_type;<br> typedef typename matrix_unary2::const_reference reference;<br> typedef typename matrix_unary2::const_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_unary2 &mu, const const_iterator1_type &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 const_iterator2:<br> public container_const_reference<matrix_unary2>,<br> public random_access_iterator_base<const_iterator2, value_type> {<br> public:<br> typedef typename E::const_iterator1::iterator_catego
|
|
ry iterator_category;<br> typedef typename matrix_unary2::difference_type difference_type;<br> typedef typename matrix_unary2::value_type value_type;<br> typedef typename matrix_unary2::const_reference reference;<br> typedef typename matrix_unary2::const_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_unary2 &mu, const const_iterator2_type &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> // Reverse iterators<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br> };</code></pre>
|
|
|
|
<h3>Unary Operations</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class E, class F><br> struct matrix_unary1_traits {<br> typedef matrix_unary1<typename E::const_closure_type, F> expression_type;<br> typedef expression_type result_type; <br> };<br><br> // (- m) [i] [j] = - m [i] [j]<br> template<class E> <br> typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type<br> operator - (const matrix_expression<E> &e);<br><br> // (conj m) [i] [j] = conj (m [i] [j])<br> template<class E> <br> typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type<br> conj (const matrix_expression<E> &e);<br><br> // (real m) [i] [j] = real (m [i] [j])<br> template<class E> <br> typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type<br> real (const matrix_expression<E> &e);<br><br> // (imag m) [i] [j] = imag (m [i] [j])<br> template<class E> <br> typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type<br> imag (const matrix_expression<E> &e);<br><br> template<class E, class F><br> struct matrix_unary2_traits {<br> typedef matrix_unary2<typename E::const_closure_type, F> expression_type;<br> typedef expression_type result_type; <br> };<br><br> // (trans m) [i] [j] = m [j] [i]<br> template<class E> <br> typename matrix_unary2_traits<E, scalar_identity<typename E::value_type> >::result_type<br> trans (const matrix_expression<E> &e);<br><br> // (herm m) [i] [j] = conj (m [j] [i])<br> template<class E> <br> typename matrix_unary2_traits<E, scalar_conj<typename E::value_type> >::result_type<br> herm (const matrix_expression<E> &e);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>operator -</code> computes the additive inverse of a matrix expression.
|
|
<code>conj </code>computes the complex conjugate of a matrix expression.<code>
|
|
real</code> and <code>imag</code> compute the real and imaginary parts
|
|
of a matrix expression. <code>trans </code>computes the transpose of a matrix
|
|
expression. <code>herm </code>computes the hermitian, i.e. the complex conjugate
|
|
of the transpose of a matrix expression.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>E</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
.</li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<p>None.</p>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the matrix expression.</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<std::complex<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) = std::complex<double> (3 * i + j, 3 * i + j);<br><br> std::cout << - m << std::endl;<br> std::cout << conj (m) << std::endl;<br> std::cout << real (m) << std::endl;<br> std::cout << imag (m) << std::endl;<br> std::cout << trans (m) << std::endl;<br> std::cout << herm (m) << std::endl;<br>}</pre>
|
|
|
|
<h3>Binary Operation Description</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_binary<E1, E2, F> </code>describes
|
|
a binary matrix operation.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E1</code> </td>
|
|
<td>The type of the first matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E2</code></td>
|
|
<td>The type of the second matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>F</code></td>
|
|
<td>The type of the operation.</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_binary<E1, E2, F> ></code>.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_binary (const expression1_type &e1,
|
|
const expression2_type &e2)</code> </td>
|
|
<td>Constructs a description of the expression.</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>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the end of the expression. </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 expression. </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 expression. </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 expression. </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 expression.</td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> template<class E1, class E2, class F><br> class matrix_binary:<br> public matrix_expression<matrix_binary<E1, E2, F> > {<br> public:<br> typedef E1 expression1_type;<br> typedef E2 expression2_type;<br> typedef F functor_type;<br> typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;<br> typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_binary<E1, E2, F> const_closure_type;<br> typedef unknown_orientation_tag orientation_category;<br> typedef typename E1::const_iterator1 const_iterator11_type;<br> typedef typename E1::const_iterator2 const_iterator12_type;<br> typedef typename E2::const_iterator1 const_iterator21_type;<br> typedef typename E2::const_iterator2 const_iterator22_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_binary ();<br> matrix_binary (const E1 &e1, const E2 &e2);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression1_type &expression1 () const;<br> const expression2_type &expression2 () const;<br><br> // Element access<br> const_reference operator () (size_type i, size_type j) const;<br><br> class const_iterator1;<br> typedef const_iterator1 iterator1;<br> class const_iterator2;<br> typedef const_iterator2 iterator2;<br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> // Element lookup<br> const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators enhance the iterators of the referenced expression<br> // with the binary functor.<br><br> class const_iterator1:<br> public container_const_reference<matrix_binary>,<br> public random_access_iterator_base<const_iterator1, value_type> {<br> public:<br> typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,<br> typename E2::const_iterator1::iterator_category>::iterator_category iterator_category;<br> typedef typename matrix_binary::difference_type difference_type;<br> typedef typename matrix_binary::value_type value_type;<br> typedef typename matrix_binary::const_reference reference;<br> typedef typename matrix_binary::const_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_binary &mb, size_type i, size_type j,<br> const const_iterator11_type &it1, const const_iterator11_type &it1_end,<br> const const_iterator21_type &it2, const const_iterator21_type &it2_end);<br><br> // Dense specializations<br> void increment (dense_random_access_iterator_tag);<br> void decrement (dense_random_access_iterator_tag);<br> value_type dereference (dense_random_access_iterator_tag) const;<br><br> // Packed specializations<br> void increment (packed_random_access_iterator_tag);<br> void decrement (packed_random_access_iterator_tag);<br> value_type dereference (packed_random_access_iterator_tag) const;<br><br> // Sparse specializations<br> void increment (sparse_bidirectional_iterator_tag);<br> void decrement (sparse_bidirectional_iterator_tag);<br> value_type dereference (sparse_bidirectional_iterator_tag) const;<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 const_iterator2:<br> public container_const_reference<matrix_binary>,<br> public random_access_iterator_base<const_iterator2, value_type> {<br> public:<br> typedef typename restrict_traits<typename E1::const_iterator2::iterator_category, <br> typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;<br> typedef typename matrix_binary::difference_type difference_type;<br> typedef typename matrix_binary::value_type value_type;<br> typedef typename matrix_binary::const_reference reference;<br> typedef typename matrix_binary::const_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_binary &mb, size_type i, size_type j,<br> const const_iterator12_type &it1, const const_iterator12_type &it1_end,<br> const const_iterator22_type &it2, const const_iterator22_type &it2_end);<br><br> // Dense specializations<br> void increment (dense_random_access_iterator_tag);<br> void decrement (dense_random_access_iterator_tag);<br> value_type dereference (dense_random_access_iterator_tag) const;<br><br> // Packed specializations<br> void increment (packed_random_access_iterator_tag);<br> void decrement (packed_random_access_iterator_tag);<br> value_type dereference (packed_random_access_iterator_tag) const;<br><br> // Sparse specializations<br> void increment (sparse_bidirectional_iterator_tag);<br> void decrement (sparse_bidirectional_iterator_tag);<br> value_type dereference (sparse_bidirectional_iterator_tag) const;<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> // Reverse iterators<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br> };</code></pre>
|
|
|
|
<h3>Binary Operations</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class E1, class E2, class F><br> struct matrix_binary_traits {<br> typedef matrix_binary<typename E1::const_closure_type, <br> typename E2::const_closure_type, F> expression_type;<br> typedef expression_type result_type; <br> };<br><br> // (m1 + m2) [i] [j] = m1 [i] [j] + m2 [i] [j]<br> template<class E1, class E2><br> typename matrix_binary_traits<E1, E2, scalar_plus<typename E1::value_type, <br> typename E2::value_type> >::result_type<br> operator + (const matrix_expression<E1> &e1, <br> const matrix_expression<E2> &e2);<br><br> // (m1 - m2) [i] [j] = m1 [i] [j] - m2 [i] [j]<br> template<class E1, class E2><br> typename matrix_binary_traits<E1, E2, scalar_minus<typename E1::value_type, <br> typename E2::value_type> >::result_type<br> operator - (const matrix_expression<E1> &e1, <br> const matrix_expression<E2> &e2);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>operator +</code> computes the sum of two matrix expressions. <code>
|
|
operator - </code>computes the difference of two matrix expressions.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>E1</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
. </li>
|
|
<li><code>E2</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
. </li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<dir> <li><code>e1 ().size1 () == e2 ().size1 ()</code> </li>
|
|
<li><code>e1 ().size2 () == e2 ().size2 ()</code></li>
|
|
</dir>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the matrix expressions.</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> m1 (3, 3), m2 (3, 3);<br> for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)<br> for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)<br> m1 (i, j) = m2 (i, j) = 3 * i + j;<br><br> std::cout << m1 + m2 << std::endl;<br> std::cout << m1 - m2 << std::endl;<br>}<br></pre>
|
|
|
|
<h3>Scalar Matrix Operation Description</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated classes <code>matrix_binary_scalar1<E1, E2, F> </code>
|
|
and <code>matrix_binary_scalar2<E1, E2, F></code> describe binary
|
|
operations between a scalar and a matrix.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E1/E2</code> </td>
|
|
<td>The type of the scalar expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E2/E1</code></td>
|
|
<td>The type of the matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>F</code></td>
|
|
<td>The type of the operation.</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_binary_scalar1<E1, E2, F> ></code>
|
|
and<code> matrix_expression<matrix_binary_scalar2<E1, E2, F> >
|
|
</code>resp.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_binary_scalar1 (const expression1_type
|
|
&e1, const expression2_type &e2)</code> </td>
|
|
<td>Constructs a description of the expression.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_binary_scalar1 (const expression1_type
|
|
&e1, const expression2_type &e2)</code> </td>
|
|
<td>Constructs a description of the expression.</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>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the end of the expression. </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 expression. </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 expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> template<class E1, class E2, class F><br> class matrix_binary_scalar1:<br> public matrix_expression<matrix_binary_scalar1<E1, E2, F> > {<br> public:<br> typedef E1 expression1_type;<br> typedef E2 expression2_type;<br> typedef F functor_type;<br> typedef typename E2::size_type size_type;<br> typedef typename E2::difference_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_binary_scalar1<E1, E2, F> const_closure_type;<br> typedef typename E2::orientation_category orientation_category;<br> typedef typename E1::value_type const_iterator1_type;<br> typedef typename E2::const_iterator1 const_iterator21_type;<br> typedef typename E2::const_iterator2 const_iterator22_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_binary_scalar1 ();<br> matrix_binary_scalar1 (const expression1_type &e1, const expression2_type &e2);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression1_type &expression1 () const;<br> const expression2_type &expression2 () const;<br><br> // Element access<br> const_reference operator () (size_type i, size_type j) const;<br><br> class const_iterator1;<br> typedef const_iterator1 iterator1;<br> class const_iterator2;<br> typedef const_iterator2 iterator2;<br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> // Element lookup<br> const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators enhance the iterators of the referenced expression<br> // with the binary functor.<br><br> class const_iterator1:<br> public container_const_reference<matrix_binary_scalar1>,<br> public random_access_iterator_base<const_iterator1, value_type> {<br> public:<br> typedef typename E2::const_iterator1::iterator_category iterator_category;<br> typedef typename matrix_binary_scalar1::difference_type difference_type;<br> typedef typename matrix_binary_scalar1::value_type value_type;<br> typedef typename matrix_binary_scalar1::const_reference reference;<br> typedef typename matrix_binary_scalar1::const_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_binary_scalar1 &mbs, const const_iterator1_type &it1, const const_iterator21_type &it2);<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>
|
|
const_iterator1 begin1 () const;
|
|
const_iterator1 end1 () const;
|
|
|
|
class const_iterator2:
|
|
public container_const_reference<matrix_binary_scalar1>,
|
|
public random_access_iterator_base<const_iterator2, value_type> {
|
|
public:
|
|
typedef typename E2::const_iterator2::iterator_category iterator_category;
|
|
typedef typename matrix_binary_scalar1::difference_type difference_type;
|
|
typedef typename matrix_binary_scalar1::value_type value_type;
|
|
typedef typename matrix_binary_scalar1::const_reference reference;
|
|
typedef typename matrix_binary_scalar1::const_pointer pointer;
|
|
typedef const_iterator1 dual_iterator_type;
|
|
typedef const_reverse_iterator1 dual_reverse_iterator_type;
|
|
|
|
// Construction and destruction
|
|
const_iterator2 ();
|
|
const_iterator2 (const matrix_binary_scalar1 &mbs, const const_iterator1_type &it1, const const_iterator22_type &it2);
|
|
|
|
// Arithmetic
|
|
const_iterator2 &operator ++ ();
|
|
const_iterator2 &operator -- ();
|
|
const_iterator2 &operator += (difference_type n);
|
|
const_iterator2 &operator -= (difference_type n);
|
|
difference_type operator - (const const_iterator2 &it) const;
|
|
|
|
// Dereference
|
|
reference operator * () const;
|
|
|
|
const_iterator1 begin () const;
|
|
const_iterator1 end () const;
|
|
const_reverse_iterator1 rbegin () const;
|
|
const_reverse_iterator1 rend () const;
|
|
|
|
// Indices
|
|
size_type index1 () const;
|
|
size_type index2 () const;
|
|
|
|
// Assignment
|
|
const_iterator2 &operator = (const const_iterator2 &it);
|
|
|
|
// Comparison
|
|
bool operator == (const const_iterator2 &it) const;
|
|
bool operator <(const const_iterator2 &it) const;
|
|
};
|
|
|
|
const_iterator2 begin2 () const;
|
|
const_iterator2 end2 () const;
|
|
|
|
// Reverse iterators
|
|
|
|
const_reverse_iterator1 rbegin1 () const;
|
|
const_reverse_iterator1 rend1 () const;
|
|
|
|
const_reverse_iterator2 rbegin2 () const;
|
|
const_reverse_iterator2 rend2 () const;
|
|
};
|
|
|
|
template<class E1, class E2, class F>
|
|
class matrix_binary_scalar2:
|
|
public matrix_expression<matrix_binary_scalar2<E1, E2, F> > {
|
|
public:
|
|
typedef E1 expression1_type;
|
|
typedef E2 expression2_type;
|
|
typedef F functor_type;
|
|
typedef typename E1::size_type size_type;
|
|
typedef typename E1::difference_type difference_type;
|
|
typedef typename F::result_type value_type;
|
|
typedef value_type const_reference;
|
|
typedef const_reference reference;
|
|
typedef const value_type *const_pointer;
|
|
typedef const_pointer pointer;
|
|
typedef const matrix_binary_scalar2<E1, E2, F> const_closure_type;
|
|
typedef typename E1::orientation_category orientation_category;
|
|
typedef typename E1::const_iterator1 const_iterator11_type;
|
|
typedef typename E1::const_iterator2 const_iterator12_type;
|
|
typedef typename E2::value_type const_iterator2_type;
|
|
typedef unknown_storage_tag storage_category;
|
|
|
|
// Construction and destruction
|
|
matrix_binary_scalar2 ();
|
|
matrix_binary_scalar2 (const expression1_type &e1, const expression2_type &e2);
|
|
|
|
// Accessors
|
|
size_type size1 () const;
|
|
size_type size2 () const;
|
|
const expression1_type &expression1 () const;
|
|
const expression2_type &expression2 () const;
|
|
|
|
// Element access
|
|
const_reference operator () (size_type i, size_type j) const;
|
|
|
|
class const_iterator1;
|
|
typedef const_iterator1 iterator1;
|
|
class const_iterator2;
|
|
typedef const_iterator2 iterator2;
|
|
typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;
|
|
typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;
|
|
|
|
// Element lookup
|
|
const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators enhance the iterators of the referenced expression<br> // with the binary functor.<br><br> class const_iterator1:<br> public container_const_reference<matrix_binary_scalar2>,<br> public random_access_iterator_base<const_iterator1, value_type> {<br> public:<br> typedef typename E1::const_iterator1::iterator_category iterator_category;<br> typedef typename matrix_binary_scalar2::difference_type difference_type;<br> typedef typename matrix_binary_scalar2::value_type value_type;<br> typedef typename matrix_binary_scalar2::const_reference reference;<br> typedef typename matrix_binary_scalar2::const_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_binary_scalar2 &mbs, const const_iterator11_type &it1, const const_iterator2_type &it2);<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 const_iterator2:<br> public container_const_reference<matrix_binary_scalar2>,<br> public random_access_iterator_base<const_iterator2, value_type> {<br> public:<br> typedef typename E1::const_iterator2::iterator_category iterator_category;<br> typedef typename matrix_binary_scalar2::difference_type difference_type;<br> typedef typename matrix_binary_scalar2::value_type value_type;<br> typedef typename matrix_binary_scalar2::const_reference reference;<br> typedef typename matrix_binary_scalar2::const_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_binary_scalar2 &mbs, const const_iterator12_type &it1, const const_iterator2_type &it2);<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> // Reverse iterators<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br> };</code></pre>
|
|
|
|
<h3>Scalar Matrix Operations </h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class T1, class E2, class F><br> struct matrix_binary_scalar1_traits {<br> typedef matrix_binary_scalar1<scalar_const_reference<T1>, <br> typename E2::const_closure_type, F> expression_type;<br> typedef expression_type result_type; <br> };<br><br> // (t * m) [i] [j] = t * m [i] [j]<br> template<class T1, class E2><br> typename matrix_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type<br> operator * (const T1 &e1, <br> const matrix_expression<E2> &e2);<br><br> template<class E1, class T2, class F><br> struct matrix_binary_scalar2_traits {<br> typedef matrix_binary_scalar2<typename E1::const_closure_type,<br> scalar_const_reference<T2>, F> expression_type;<br> typedef expression_type result_type; <br> };<br><br> // (m * t) [i] [j] = m [i] [j] * t<br> template<class E1, class T2><br> typename matrix_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type<br> operator * (const matrix_expression<E1> &e1, <br> const T2 &e2);<br><br> // (m / t) [i] [j] = m [i] [j] / t<br> template<class E1, class T2><br> typename matrix_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type<br> operator / (const matrix_expression<E1> &e1, <br> const T2 &e2);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>operator *</code> computes the product of a scalar and a matrix expression.
|
|
<code>operator /</code> multiplies the matrix with the reciprocal of the
|
|
scalar. </p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>T1/T2</code> is a model of <a href="expression.htm#scalar_expression">
|
|
Scalar Expression</a>
|
|
. </li>
|
|
<li><code>E2/E1</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
.</li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<p>None.</p>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the matrix expression.</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> m (i, j) = 3 * i + j;<br><br> std::cout << 2.0 * m << std::endl;<br> std::cout << m * 2.0 << std::endl;<br>}</pre>
|
|
|
|
<h2></h2>
|
|
|
|
<pre></pre>
|
|
|
|
<h2><a name="matrix_vector_operations"></a>
|
|
Matrix Vector Operations</h2>
|
|
|
|
<h3>Binary Operation Description</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated classes <code>matrix_vector_binary1<E1, E2, F> </code>
|
|
and <code>matrix_vector_binary2<E1, E2, F> </code>describe binary
|
|
matrix vector operations.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E1</code> </td>
|
|
<td>The type of the matrix or vector expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E2</code> </td>
|
|
<td>The type of the vector or matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>F</code> </td>
|
|
<td>The type of the operation.</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_binary1<E1, E2, F> ></code>
|
|
and <code>vector_expression<matrix_vector_binary2<E1, E2, F> ></code>
|
|
resp.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_vector_binary1 (const expression1_type
|
|
&e1, const expression2_type &e2)</code></td>
|
|
<td>Constructs a description of the expression.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_vector_binary2 (const expression1_type
|
|
&e1, const expression2_type &e2)</code></td>
|
|
<td>Constructs a description of the expression.</td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>size_type size () const</code></td>
|
|
<td>Returns the size of the expression. </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>const_iterator begin () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the
|
|
beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator end () const</code></td>
|
|
<td>Returns a <code>const_iterator</code> pointing to the
|
|
end of the expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> template<class E1, class E2, class F><br> class matrix_vector_binary1:<br> public vector_expression<matrix_vector_binary1<E1, E2, F> > {<br> public:<br> typedef E1 expression1_type;<br> typedef E2 expression2_type;<br> typedef F functor_type;<br> typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;<br> typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_vector_binary1<E1, E2, F> const_closure_type;<br> typedef typename E1::const_iterator1 const_iterator1_type;<br> typedef typename E2::const_iterator const_iterator2_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_vector_binary1 ();<br> matrix_vector_binary1 (const expression1_type &e1, const expression2_type &e2);<br><br> // Accessors<br> size_type size () const;<br> const expression1_type &expression1 () const;<br> const expression2_type &expression2 () const;<br><br> // Element access<br> const_reference operator () (size_type i) const;<br><br> class const_iterator;<br> typedef const_iterator iterator;<br><br> // Element lookup<br> const_iterator find_first (size_type i) const;<br> const_iterator find_last (size_type i) const;<br><br> // Iterator simply is a pointer.<br><br> class const_iterator:<br> public container_const_reference<matrix_vector_binary1>,<br> public random_access_iterator_base<const_iterator, value_type> {<br> public:<br> typedef typename restrict_traits<typename E1::const_iterator1::iterator_category, <br> typename E2::const_iterator::iterator_category>::iterator_category iterator_category;<br> typedef typename matrix_vector_binary1::difference_type difference_type;<br> typedef typename matrix_vector_binary1::value_type value_type;<br> typedef typename matrix_vector_binary1::const_reference reference;<br> typedef typename matrix_vector_binary1::const_pointer pointer;<br><br> // Construction and destruction<br> const_iterator ();<br> const_iterator (const matrix_vector_binary1 &mvb, const const_iterator1_type &it1);<br><br> // Dense random access specialization<br> value_type dereference (dense_random_access_iterator_tag) const;<br><br> // Packed bidirectional specialization<br> value_type dereference (packed_bidirectional_iterator_tag) const;<br><br> // Sparse bidirectional specialization<br> value_type dereference (sparse_bidirectional_iterator_tag) const;<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> // 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><br> template<class E1, class E2, class F><br> class matrix_vector_binary2:<br> public vector_expression<matrix_vector_binary2<E1, E2, F> > {<br> public:<br> typedef E1 expression1_type;<br> typedef E2 expression2_type;<br> typedef F functor_type;<br> typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;<br> typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_vector_binary2<E1, E2, F> const_closure_type;<br> typedef typename E1::const_iterator const_iterator1_type;<br> typedef typename E2::const_iterator2 const_iterator2_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_vector_binary2 ();<br> matrix_vector_binary2 (const expression1_type &e1, const expression2_type &e2);<br><br> // Accessors<br> size_type size () const;<br> const expression1_type &expression1 () const;<br> const expression2_type &expression2 () const;<br><br> // Element access<br> const_reference operator () (size_type j) const;<br><br> class const_iterator;<br> typedef const_iterator iterator;<br><br> // Element lookup<br> const_iterator find_first (size_type j) const;<br> const_iterator find_last (size_type j) const;<br><br> // Iterator simply is a pointer.<br><br> class const_iterator:<br> public container_const_reference<matrix_vector_binary2>,<br> public random_access_iterator_base<const_iterator, value_type> {<br> public:<br> typedef typename restrict_traits<typename E1::const_iterator::iterator_category, <br> typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;<br> typedef typename matrix_vector_binary2::difference_type difference_type;<br> typedef typename matrix_vector_binary2::value_type value_type;<br> typedef typename matrix_vector_binary2::const_reference reference;<br> typedef typename matrix_vector_binary2::const_pointer pointer;<br><br> // Construction and destruction<br> const_iterator ();<br> const_iterator (const matrix_vector_binary2 &mvb, const const_iterator2_type &it2);<br><br> // Dense random access specialization<br> value_type dereference (dense_random_access_iterator_tag) const;<br><br> // Packed bidirectional specialization<br> value_type dereference (packed_bidirectional_iterator_tag) const;<br><br> // Sparse bidirectional specialization<br> value_type dereference (sparse_bidirectional_iterator_tag) const;<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> // 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> };</code></pre>
|
|
|
|
<h3>Binary Operations</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class T1, class E1, class T2, class E2><br> struct matrix_vector_binary1_traits {<br> typedef row_major_tag dispatch_category;<br> typedef typename promote_traits<T1, T2>::promote_type promote_type;<br> typedef matrix_vector_binary1<typename E1::const_closure_type, <br> typename E2::const_closure_type, <br> matrix_vector_prod1<T1, T2, promote_type> > expression_type;<br> typedef expression_type result_type; <br> };<br><br> template<class E1, class E2><br> typename matrix_vector_binary1_traits<typename E1::value_type, E1, <br> typename E2::value_type, E2>::result_type<br> prod (const matrix_expression<E1> &e1, <br> const vector_expression<E2> &e2,<br> row_major_tag);<br><br> // Dispatcher<br> template<class E1, class E2><br> typename matrix_vector_binary1_traits<typename E1::value_type, E1, <br> typename E2::value_type, E2>::result_type<br> prod (const matrix_expression<E1> &e1, <br> const vector_expression<E2> &e2);<br><br> template<class E1, class E2><br> typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1, <br> typename type_traits<typename E2::value_type>::precision_type, E2>::result_type<br> prec_prod (const matrix_expression<E1> &e1, <br> const vector_expression<E2> &e2,<br> row_major_tag);<br><br> // Dispatcher<br> template<class E1, class E2><br> typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1, <br> typename type_traits<typename E2::value_type>::precision_type, E2>::result_type<br> prec_prod (const matrix_expression<E1> &e1, <br> const vector_expression<E2> &e2);<br><br> template<class V, class E1, class E2><br> V<br> prod (const matrix_expression<E1> &e1,<br> const vector_expression<E2> &e2);<br><br> template<class V, class E1, class E2><br> V<br> prec_prod (const matrix_expression<E1> &e1,<br> const vector_expression<E2> &e2);<br><br> template<class T1, class E1, class T2, class E2><br> struct matrix_vector_binary2_traits {<br> typedef column_major_tag dispatch_category;<br> typedef typename promote_traits<T1, T2>::promote_type promote_type;<br> typedef matrix_vector_binary2<typename E1::const_closure_type, <br> typename E2::const_closure_type, <br> matrix_vector_prod2<T1, T2, promote_type> > expression_type;<br> typedef expression_type result_type; <br> };<br><br> template<class E1, class E2><br> typename matrix_vector_binary2_traits<typename E1::value_type, E1, <br> typename E2::value_type, E2>::result_type<br> prod (const vector_expression<E1> &e1, <br> const matrix_expression<E2> &e2,<br> column_major_tag);<br><br> // Dispatcher<br> template<class E1, class E2><br> typename matrix_vector_binary2_traits<typename E1::value_type, E1, <br> typename E2::value_type, E2>::result_type<br> prod (const vector_expression<E1> &e1, <br> const matrix_expression<E2> &e2);<br><br> template<class E1, class E2><br> typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1, <br> typename type_traits<typename E2::value_type>::precision_type, E2>::result_type<br> prec_prod (const vector_expression<E1> &e1, <br> const matrix_expression<E2> &e2,<br> column_major_tag);<br><br> // Dispatcher<br> template<class E1, class E2><br> typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1, <br> typename type_traits<typename E2::value_type>::precision_type, E2>::result_type<br> prec_prod (const vector_expression<E1> &e1, <br> const matrix_expression<E2> &e2);<br><br> template<class V, class E1, class E2><br> V<br> prod (const vector_expression<E1> &e1,<br> const matrix_expression<E2> &e2);<br><br> template<class V, class E1, class E2><br> V<br> prec_prod (const vector_expression<E1> &e1,<br> const matrix_expression<E2> &e2);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>prod</code> computes the product of the matrix and the vector expression.<code>
|
|
prec_prod</code> computes the double precision product of the matrix and
|
|
the vector expression.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>E1</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
or <a href="expression.htm#vector_expression">Vector
|
|
Expression</a>
|
|
. </li>
|
|
<li><code>E2</code> is a model of <a href="expression.htm#vector_expression">
|
|
Vector Expression</a>
|
|
or <a href="expression.htm#matrix_expression">Matrix Expression</a>
|
|
.</li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<dir> <li><code>e1 ().size2 () == e2 ().size ()</code> </li>
|
|
<li><code>e1 ().size () == e2 ().size1 ()</code></li>
|
|
</dir>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the matrix expression.</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> vector<double> v (3);<br> for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {<br> for (unsigned j = 0; j < m.size2 (); ++ j)<br> m (i, j) = 3 * i + j;<br> v (i) = i;<br> }<br><br> std::cout << prod (m, v) << std::endl;<br> std::cout << prod (v, m) << std::endl;<br>}</pre>
|
|
|
|
<h3>Triangular Solver</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class E1, class E2><br> struct matrix_vector_solve_traits {<br> typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;<br> typedef vector<promote_type> result_type;<br> };<br><br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1, <br> E2 &e2,<br> lower_tag,<br> vector_tag);<br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1, <br> E2 &e2,<br> upper_tag,<br> vector_tag);<br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1, <br> E2 &e2,<br> unit_lower_tag,<br> vector_tag);<br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1, <br> E2 &e2,<br> unit_upper_tag,<br> vector_tag);<br><br> template<class E1, class E2, class C><br> typename matrix_vector_solve_traits<E1, E2>::result_type<br> solve (const matrix_expression<E1> &e1, <br> const vector_expression<E2> &e2,<br> C);<br><br> template<class E1, class E2><br> void inplace_solve (E1 &e1,<br> const matrix_expression<E2> &e2, <br> vector_tag, <br> lower_tag);<br> template<class E1, class E2><br> void inplace_solve (E1 &e1,<br> const matrix_expression<E2> &e2, <br> vector_tag, <br> upper_tag);<br> template<class E1, class E2><br> void inplace_solve (E1 &e1,<br> const matrix_expression<E2> &e2, <br> vector_tag, <br> unit_lower_tag);<br> template<class E1, class E2><br> void inplace_solve (E1 &e1,<br> const matrix_expression<E2> &e2, <br> vector_tag, <br> unit_upper_tag);<br><br> template<class E1, class E2, class C><br> typename matrix_vector_solve_traits<E1, E2>::result_type<br> solve (const vector_expression<E1> &e1, <br> const matrix_expression<E2> &e2,<br> C);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>solve</code> solves a linear equation for lower or upper (unit) triangular
|
|
matrices.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header triangular.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>E1</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
or <a href="expression.htm#vector_expression">Vector Expression</a>
|
|
. </li>
|
|
<li><code>E2</code> is a model of <a href="expression.htm#vector_expression">
|
|
Vector Expression</a>
|
|
or <a href="expression.htm#matrix_expression">Matrix Expression</a>
|
|
.</li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<dir> <li><code>e1 ().size1 () == e1 ().size2 ()</code> </li>
|
|
<li><code>e1 ().size2 () == e2 ().size ()</code> </li>
|
|
<li><code>e1 ().size () == e2 ().size1 ()</code> </li>
|
|
<li><code>e2 ().size1 () == e2 ().size2 ()</code></li>
|
|
</dir>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Quadratic depending from the size of the matrix expression.</p>
|
|
|
|
<h4>Examples</h4>
|
|
|
|
<pre>#include <boost/numeric/ublas/triangular.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> vector<double> v (3);<br> for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {<br> for (unsigned j = 0; j <= i; ++ j)<br> m (i, j) = 3 * i + j + 1;<br> v (i) = i;<br> }<br><br> std::cout << solve (m, v, lower_tag ()) << std::endl;<br> std::cout << solve (v, m, lower_tag ()) << std::endl;<br>}<br></pre>
|
|
|
|
<h2><a name="matrix_matrix_operations"></a>
|
|
Matrix Matrix Operations</h2>
|
|
|
|
<h3>Binary Operation Description</h3>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p>The templated class <code>matrix_matrix_binary<E1, E2, F> </code>
|
|
describes a binary matrix operation.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Template parameters</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Parameter </th>
|
|
<th>Description </th>
|
|
<th>Default </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E1</code> </td>
|
|
<td>The type of the first matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>E2</code></td>
|
|
<td>The type of the second matrix expression. </td>
|
|
<td> </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>F</code></td>
|
|
<td>The type of the operation.</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_matrix_binary<E1, E2, F> ></code>
|
|
.</p>
|
|
|
|
<h4>Members</h4>
|
|
|
|
<table border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th>Member </th>
|
|
<th>Description </th>
|
|
</tr>
|
|
<tr>
|
|
<td><code>matrix_matrix_binary (const expression1_type
|
|
&e1, const expression2_type &e2)</code> </td>
|
|
<td>Constructs a description of the expression.</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>const_iterator1 begin1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator1 end1 () const</code></td>
|
|
<td>Returns a <code>const_iterator1</code> pointing to
|
|
the end of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 begin2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the beginning of the expression. </td>
|
|
</tr>
|
|
<tr>
|
|
<td><code>const_iterator2 end2 () const</code></td>
|
|
<td>Returns a <code>const_iterator2</code> pointing to
|
|
the end of the expression. </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 expression. </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 expression. </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 expression. </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 expression. </td>
|
|
</tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
<h4>Interface</h4>
|
|
|
|
<pre><code> template<class E1, class E2, class F><br> class matrix_matrix_binary:<br> public matrix_expression<matrix_matrix_binary<E1, E2, F> > {<br> public:<br> typedef E1 expression1_type;<br> typedef E2 expression2_type;<br> typedef F functor_type;<br> typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type;<br> typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type;<br> typedef typename F::result_type value_type;<br> typedef value_type const_reference;<br> typedef const_reference reference;<br> typedef const value_type *const_pointer;<br> typedef const_pointer pointer;<br> typedef const matrix_matrix_binary<E1, E2, F> const_closure_type;<br> typedef unknown_orientation_tag orientation_category;<br> typedef typename E1::const_iterator1 const_iterator11_type;<br> typedef typename E1::const_iterator2 const_iterator12_type;<br> typedef typename E2::const_iterator1 const_iterator21_type;<br> typedef typename E2::const_iterator2 const_iterator22_type;<br> typedef unknown_storage_tag storage_category;<br><br> // Construction and destruction<br> matrix_matrix_binary ();<br> matrix_matrix_binary (const expression1_type &e1, const expression2_type &e2);<br><br> // Accessors<br> size_type size1 () const;<br> size_type size2 () const;<br> const expression1_type &expression1 () const;<br> const expression2_type &expression2 () const;<br><br> // Element access<br> const_reference operator () (size_type i, size_type j) const;<br><br> class const_iterator1;<br> typedef const_iterator1 iterator1;<br> class const_iterator2;<br> typedef const_iterator2 iterator2;<br> typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;<br> typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;<br><br> // Element lookup<br> const_iterator1 find_first1 (int rank, size_type i, size_type j) const;<br> const_iterator1 find_last1 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_first2 (int rank, size_type i, size_type j) const;<br> const_iterator2 find_last2 (int rank, size_type i, size_type j) const;<br><br> // Iterators simply are pointers.<br><br> class const_iterator1:<br> public container_const_reference<matrix_matrix_binary>,<br> public random_access_iterator_base<const_iterator1, value_type> {<br> public:<br> typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,<br> typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;<br> typedef typename matrix_matrix_binary::difference_type difference_type;<br> typedef typename matrix_matrix_binary::value_type value_type;<br> typedef typename matrix_matrix_binary::const_reference reference;<br> typedef typename matrix_matrix_binary::const_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_matrix_binary &mmb, const const_iterator11_type &it1, const const_iterator22_type &it2);<br><br> // Random access specialization<br> value_type dereference (dense_random_access_iterator_tag) const;<br><br> // Packed bidirectional specialization<br> value_type dereference (packed_bidirectional_iterator_tag) const;<br><br> // Sparse bidirectional specialization<br> value_type dereference (sparse_bidirectional_iterator_tag) const;<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 const_iterator2:<br> public container_const_reference<matrix_matrix_binary>,<br> public random_access_iterator_base<const_iterator2, value_type> {<br> public:<br> typedef typename restrict_traits<typename E1::const_iterator1::iterator_category,<br> typename E2::const_iterator2::iterator_category>::iterator_category iterator_category;<br> typedef typename matrix_matrix_binary::difference_type difference_type;<br> typedef typename matrix_matrix_binary::value_type value_type;<br> typedef typename matrix_matrix_binary::const_reference reference;<br> typedef typename matrix_matrix_binary::const_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_matrix_binary &mmb, const const_iterator11_type &it1, const const_iterator22_type &it2);<br><br> // Random access specialization<br> value_type dereference (dense_random_access_iterator_tag) const;<br><br> // Packed bidirectional specialization<br> value_type dereference (packed_bidirectional_iterator_tag) const;<br><br> // Sparse bidirectional specialization<br> value_type dereference (sparse_bidirectional_iterator_tag) const;<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> // Reverse iterators<br><br> const_reverse_iterator1 rbegin1 () const;<br> const_reverse_iterator1 rend1 () const;<br><br> const_reverse_iterator2 rbegin2 () const;<br> const_reverse_iterator2 rend2 () const;<br> };</code></pre>
|
|
|
|
<h3>Binary Operations</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class T1, class E1, class T2, class E2><br> struct matrix_matrix_binary_traits {<br> typedef unknown_orientation_tag dispatch_category;<br> typedef typename promote_traits<T1, T2>::promote_type promote_type;<br> typedef matrix_matrix_binary<typename E1::const_closure_type,<br> typename E2::const_closure_type,<br> matrix_matrix_prod<T1, T2, promote_type> > expression_type;<br> typedef expression_type result_type;<br> };<br><br> template<class E1, class E2><br> typename matrix_matrix_binary_traits<typename E1::value_type, E1,<br> typename E2::value_type, E2>::result_type<br> prod (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2,<br> unknown_orientation_tag);<br><br> // Dispatcher<br> template<class E1, class E2><br> typename matrix_matrix_binary_traits<typename E1::value_type, E1,<br> typename E2::value_type, E2>::result_type<br> prod (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2);<br><br> template<class E1, class E2><br> typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,<br> typename type_traits<typename E2::value_type>::precision_type, E2>::result_type<br> prec_prod (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2,<br> unknown_orientation_tag);<br><br> // Dispatcher<br> template<class E1, class E2><br> typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,<br> typename type_traits<typename E2::value_type>::precision_type, E2>::result_type<br> prec_prod (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2);<br><br> template<class M, class E1, class E2><br> M<br> prod (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2);<br><br> template<class M, class E1, class E2><br> M<br> prec_prod (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>prod</code> computes the product of the matrix expressions.<code>
|
|
prec_prod</code> computes the double precision product of the matrix expressions.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header matrix_expression.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>E1</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
. </li>
|
|
<li><code>E2</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
.</li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<dir> <li><code>e1 ().size2 () == e2 ().size1 ()</code></li>
|
|
</dir>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Cubic depending from the size of the matrix expression.</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> m1 (3, 3), m2 (3, 3);<br> for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)<br> for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)<br> m1 (i, j) = m2 (i, j) = 3 * i + j;<br><br> std::cout << prod (m1, m2) << std::endl;<br>}<br></pre>
|
|
|
|
<h3>Triangular Solvers</h3>
|
|
|
|
<h4>Prototypes</h4>
|
|
|
|
<pre><code> template<class E1, class E2><br> struct matrix_matrix_solve_traits {<br> typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;<br> typedef matrix<promote_type> result_type;<br> };<br><br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1,<br> E2 &e2,<br> lower_tag,<br> matrix_tag);<br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1,<br> E2 &e2,<br> upper_tag,<br> matrix_tag);<br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1,<br> E2 &e2,<br> unit_lower_tag,<br> matrix_tag);<br> template<class E1, class E2><br> void inplace_solve (const matrix_expression<E1> &e1,<br> E2 &e2,<br> unit_upper_tag,<br> matrix_tag);<br><br> template<class E1, class E2, class C><br> typename matrix_matrix_solve_traits<E1, E2>::result_type<br> solve (const matrix_expression<E1> &e1,<br> const matrix_expression<E2> &e2,<br> C);</code></pre>
|
|
|
|
<h4>Description</h4>
|
|
|
|
<p><code>solve</code> solves a linear equation for lower or upper (unit) triangular
|
|
matrices.</p>
|
|
|
|
<h4>Definition</h4>
|
|
|
|
<p>Defined in the header triangular.hpp.</p>
|
|
|
|
<h4>Type requirements</h4>
|
|
|
|
<dir> <li><code>E1</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
. </li>
|
|
<li><code>E2</code> is a model of <a href="expression.htm#matrix_expression">
|
|
Matrix Expression</a>
|
|
.</li>
|
|
</dir>
|
|
|
|
<h4>Preconditions</h4>
|
|
|
|
<dir> <li><code>e1 ().size1 () == e1 ().size2 ()</code> </li>
|
|
<li><code>e1 ().size2 () == e2 ().size1 ()</code></li>
|
|
</dir>
|
|
|
|
<h4>Complexity</h4>
|
|
|
|
<p>Cubic depending from the size of the matrix expressions.</p>
|
|
|
|
<h4>Examples</h4>
|
|
|
|
<pre>#include <boost/numeric/ublas/triangular.hpp><br>#include <boost/numeric/ublas/io.hpp><br><br>int main () {<br> using namespace boost::numeric::ublas;<br> matrix<double> m1 (3, 3), m2 (3, 3);<br> for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)<br> for (unsigned j = 0; j <= i; ++ j)<br> m1 (i, j) = m2 (i, j) = 3 * i + j + 1;<br><br> std::cout << solve (m1, m2, lower_tag ()) << 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>
|