<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta name="generator" content="HTML Tidy, see www.w3.org"> <meta http-equiv="Content-Type" content= "text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0"> <title>Triangular Matrix</title> </head> <body bgcolor="#ffffff"> <h1><img src="c++boost.gif" alt="c++boost.gif" align="Center"> Triangular Matrix</h1> <h2><a name="triangular_matrix"></a> Triangular Matrix</h2> <h4>Description</h4> <p>The templated class <code>triangular_matrix<T, F1, F2, A></code> is the base container adaptor for triangular matrices. For a <em>(n x n</em> )-dimensional lower triangular matrix and <em>0 <= i < n</em>,<em>0 <= j < n</em> holds <em>t</em><sub><em>i, j</em></sub> <em>= 0</em> , if <em>i > j</em>. If furthermore holds t<sub><em>i, i</em></sub><em>= 1</em> the matrix is called unit lower triangular. For a <em>(n x n</em> )-dimensional upper triangular matrix and <em>0 <= i < n</em>,<em>0 <= j < n</em> holds <em>t</em><sub><em>i, j</em></sub> <em>= 0</em> , if <em>i < j</em>. If furthermore holds t<sub><em>i, i</em></sub><em>= 1</em> the matrix is called unit lower triangular. The storage of triangular matrices is packed.</p> <h4>Example</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> triangular_matrix<double, lower> ml (3, 3);<br> for (unsigned i = 0; i < ml.size1 (); ++ i)<br> for (unsigned j = 0; j <= i; ++ j)<br> ml (i, j) = 3 * i + j;<br> std::cout << ml << std::endl;<br> triangular_matrix<double, upper> mu (3, 3);<br> for (unsigned i = 0; i < mu.size1 (); ++ i)<br> for (unsigned j = i; j < mu.size2 (); ++ j)<br> mu (i, j) = 3 * i + j;<br> std::cout << mu << std::endl;<br> }<br> </pre> <h4>Definition</h4> <p>Defined in the header triangular.hpp.</p> <h4>Template parameters</h4> <table border="1"> <tbody> <tr> <th>Parameter</th> <th>Description</th> <th>Default</th> </tr> <tr> <td><code>T</code> </td> <td>The type of object stored in the matrix.</td> <td> </td> </tr> <tr> <td><code>F1</code></td> <td>Functor describing the type of the triangular matrix. <a href= "#triangular_matrix_1">[1]</a> </td> <td><code>lower</code></td> </tr> <tr> <td><code>F2</code></td> <td>Functor describing the storage organization. <a href= "#triangular_matrix_2">[2]</a> </td> <td><code>row_major</code></td> </tr> <tr> <td><code>A</code></td> <td>The type of the adapted array. <a href= "#triangular_matrix_3">[3]</a> </td> <td><code>unbounded_array<T></code></td> </tr> </tbody> </table> <h4>Model of</h4> <p><a href="container.htm#matrix">Matrix</a> .</p> <h4>Type requirements</h4> <p>None, except for those imposed by the requirements of <a href= "container.htm#matrix">Matrix</a> .</p> <h4>Public base classes</h4> <p><code>matrix_expression<triangular_matrix<T, F1, F2, A> ></code></p> <h4>Members</h4> <table border="1"> <tbody> <tr> <th>Member</th> <th>Description</th> </tr> <tr> <td><code>triangular_matrix ()</code> </td> <td>Allocates an uninitialized <code>triangular_matrix</code> that holds zero rows of zero elements.</td> </tr> <tr> <td><code>triangular_matrix (size_type size1, size_type size2)</code></td> <td>Allocates an uninitialized <code>triangular_matrix</code> that holds <code>size1</code> rows of <code>size2</code> elements.</td> </tr> <tr> <td><code>triangular_matrix (const triangular_matrix &m)</code></td> <td>The copy constructor.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix (const matrix_expression<AE> &ae)</code></td> <td>The extended copy constructor.</td> </tr> <tr> <td><code>void resize (size_type size1, size_type size2)</code></td> <td>Reallocates a <code>triangular_matrix</code> to hold <code>size1</code> rows of <code>size2</code> elements. The content of the <code>triangular_matrix</code> is not preserved.</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 a <code>const</code> reference 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>triangular_matrix &operator = (const triangular_matrix &m)</code></td> <td>The assignment operator.</td> </tr> <tr> <td><code>triangular_matrix &assign_temporary (triangular_matrix &m)</code></td> <td>Assigns a temporary. May change the triangular matrix <code>m</code>.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix &operator = (const matrix_expression<AE> &ae)</code></td> <td>The extended assignment operator.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix &assign (const matrix_expression<AE> &ae)</code></td> <td>Assigns a matrix expression to the triangular matrix. Left and right hand side of the assignment should be independent.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix &operator += (const matrix_expression<AE> &ae)</code></td> <td>A computed assignment operator. Adds the matrix expression to the triangular matrix.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix &plus_assign (const matrix_expression<AE> &ae)</code></td> <td>Adds a matrix expression to the triangular matrix. Left and right hand side of the assignment should be independent.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix &operator -= (const matrix_expression<AE> &ae)</code></td> <td>A computed assignment operator. Subtracts the matrix expression from the triangular matrix.</td> </tr> <tr> <td><code>template<class AE><br> triangular_matrix &minus_assign (const matrix_expression<AE> &ae)</code></td> <td>Subtracts a matrix expression from the triangular matrix. Left and right hand side of the assignment should be independent.</td> </tr> <tr> <td><code>template<class AT><br> triangular_matrix &operator *= (const AT &at)</code></td> <td>A computed assignment operator. Multiplies the triangular matrix with a scalar.</td> </tr> <tr> <td><code>template<class AT><br> triangular_matrix &operator /= (const AT &at)</code></td> <td>A computed assignment operator. Divides the triangular matrix through a scalar.</td> </tr> <tr> <td><code>void swap (triangular_matrix &m)</code></td> <td>Swaps the contents of the triangular matrices.</td> </tr> <tr> <td><code>void insert (size_type i, size_type j, const_reference t)</code></td> <td>Inserts the value <code>t</code> at the <code>j</code>-th element of the <code>i</code>-th row.</td> </tr> <tr> <td><code>void erase (size_type i, size_type j)</code></td> <td>Erases the value at the <code>j</code>-th elemenst of the <code>i</code>-th row.</td> </tr> <tr> <td><code>void clear ()</code></td> <td>Clears the matrix.</td> </tr> <tr> <td><code>const_iterator1 begin1 () const</code></td> <td>Returns a <code>const_iterator1</code> pointing to the beginning of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_iterator1 end1 () const</code></td> <td>Returns a <code>const_iterator1</code> pointing to the end of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>iterator1 begin1 ()</code> </td> <td>Returns a <code>iterator1</code> pointing to the beginning of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>iterator1 end1 ()</code> </td> <td>Returns a <code>iterator1</code> pointing to the end of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_iterator2 begin2 () const</code></td> <td>Returns a <code>const_iterator2</code> pointing to the beginning of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_iterator2 end2 () const</code></td> <td>Returns a <code>const_iterator2</code> pointing to the end of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>iterator2 begin2 ()</code> </td> <td>Returns a <code>iterator2</code> pointing to the beginning of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>iterator2 end2 ()</code> </td> <td>Returns a <code>iterator2</code> pointing to the end of the <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_reverse_iterator1 rbegin1 () const</code></td> <td>Returns a <code>const_reverse_iterator1</code> pointing to the beginning of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_reverse_iterator1 rend1 () const</code></td> <td>Returns a <code>const_reverse_iterator1</code> pointing to the end of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>reverse_iterator1 rbegin1 ()</code> </td> <td>Returns a <code>reverse_iterator1</code> pointing to the beginning of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>reverse_iterator1 rend1 ()</code> </td> <td>Returns a <code>reverse_iterator1</code> pointing to the end of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_reverse_iterator2 rbegin2 () const</code></td> <td>Returns a <code>const_reverse_iterator2</code> pointing to the beginning of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>const_reverse_iterator2 rend2 () const</code></td> <td>Returns a <code>const_reverse_iterator2</code> pointing to the end of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>reverse_iterator2 rbegin2 ()</code> </td> <td>Returns a <code>reverse_iterator2</code> pointing to the beginning of the reversed <code>triangular_matrix</code>.</td> </tr> <tr> <td><code>reverse_iterator2 rend2 ()</code> </td> <td>Returns a <code>reverse_iterator2</code> pointing to the end of the reversed <code>triangular_matrix</code>.</td> </tr> </tbody> </table> <h4>Notes</h4> <p><a name="#triangular_matrix_1">[1]</a> Supported parameters for the type of the triangular matrix are <code>lower</code> , <code>unit_lower</code>, <code>upper</code> and <code>unit_upper</code> .</p> <p><a name="#triangular_matrix_2">[2]</a> Supported parameters for the storage organization are <code>row_major</code> and <code>column_major</code>.</p> <p><a name="#triangular_matrix_3">[3]</a> Supported parameters for the adapted array are <code>unbounded_array<T></code> , <code>bounded_array<T></code> and <code>std::vector<T></code> .</p> <h2><a name="triangular_adaptor"></a> Triangular Adaptor</h2> <h4>Description</h4> <p>The templated class <code>triangular_adaptor<M, F></code> is a triangular matrix adaptor for other matrices.</p> <h4>Example</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> triangular_adaptor<matrix<double>, lower> tal (m);<br> for (unsigned i = 0; i < tal.size1 (); ++ i)<br> for (unsigned j = 0; j <= i; ++ j)<br> tal (i, j) = 3 * i + j;<br> std::cout << tal << std::endl;<br> triangular_adaptor<matrix<double>, upper> tau (m);<br> for (unsigned i = 0; i < tau.size1 (); ++ i)<br> for (unsigned j = i; j < tau.size2 (); ++ j)<br> tau (i, j) = 3 * i + j;<br> std::cout << tau << std::endl;<br> }<br> </pre> <h4>Definition</h4> <p>Defined in the header triangular.hpp.</p> <h4>Template parameters</h4> <table border="1"> <tbody> <tr> <th>Parameter</th> <th>Description</th> <th>Default</th> </tr> <tr> <td><code>M</code></td> <td>The type of the adapted matrix.</td> <td> </td> </tr> <tr> <td><code>F</code></td> <td>Functor describing the type of the triangular adaptor. <a href= "#triangular_adaptor_1">[1]</a> </td> <td><code>lower</code></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<triangular_adaptor<M, F> ></code></p> <h4>Members</h4> <table border="1"> <tbody> <tr> <th>Member</th> <th>Description</th> </tr> <tr> <td><code>triangular_adaptor ()</code> </td> <td>Constructs a <code>triangular_adaptor</code> that holds zero rows of zero elements.</td> </tr> <tr> <td><code>triangular_adaptor (matrix_type &data)</code></td> <td>Constructs a <code>triangular_adaptor</code> of a matrix.</td> </tr> <tr> <td><code>triangular_adaptor (const triangular_adaptor &m)</code></td> <td>The copy constructor.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor (const matrix_expression<AE> &ae)</code></td> <td>The extended copy constructor.</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 a <code>const</code> reference 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>triangular_adaptor &operator = (const triangular_adaptor &m)</code></td> <td>The assignment operator.</td> </tr> <tr> <td><code>triangular_adaptor &assign_temporary (triangular_adaptor &m)</code></td> <td>Assigns a temporary. May change the triangular adaptor <code>m</code>.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor &operator = (const matrix_expression<AE> &ae)</code></td> <td>The extended assignment operator.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor &assign (const matrix_expression<AE> &ae)</code></td> <td>Assigns a matrix expression to the triangular adaptor. Left and right hand side of the assignment should be independent.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor &operator += (const matrix_expression<AE> &ae)</code></td> <td>A computed assignment operator. Adds the matrix expression to the triangular adaptor.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor &plus_assign (const matrix_expression<AE> &ae)</code></td> <td>Adds a matrix expression to the triangular adaptor. Left and right hand side of the assignment should be independent.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor &operator -= (const matrix_expression<AE> &ae)</code></td> <td>A computed assignment operator. Subtracts the matrix expression from the triangular adaptor.</td> </tr> <tr> <td><code>template<class AE><br> triangular_adaptor &minus_assign (const matrix_expression<AE> &ae)</code></td> <td>Subtracts a matrix expression from the triangular adaptor. Left and right hand side of the assignment should be independent.</td> </tr> <tr> <td><code>template<class AT><br> triangular_adaptor &operator *= (const AT &at)</code></td> <td>A computed assignment operator. Multiplies the triangular adaptor with a scalar.</td> </tr> <tr> <td><code>template<class AT><br> triangular_adaptor &operator /= (const AT &at)</code></td> <td>A computed assignment operator. Divides the triangular adaptor through a scalar.</td> </tr> <tr> <td><code>void swap (triangular_adaptor &m)</code></td> <td>Swaps the contents of the triangular adaptors.</td> </tr> <tr> <td><code>const_iterator1 begin1 () const</code></td> <td>Returns a <code>const_iterator1</code> pointing to the beginning of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_iterator1 end1 () const</code></td> <td>Returns a <code>const_iterator1</code> pointing to the end of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>iterator1 begin1 ()</code> </td> <td>Returns a <code>iterator1</code> pointing to the beginning of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>iterator1 end1 ()</code> </td> <td>Returns a <code>iterator1</code> pointing to the end of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_iterator2 begin2 () const</code></td> <td>Returns a <code>const_iterator2</code> pointing to the beginning of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_iterator2 end2 () const</code></td> <td>Returns a <code>const_iterator2</code> pointing to the end of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>iterator2 begin2 ()</code> </td> <td>Returns a <code>iterator2</code> pointing to the beginning of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>iterator2 end2 ()</code> </td> <td>Returns a <code>iterator2</code> pointing to the end of the <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_reverse_iterator1 rbegin1 () const</code></td> <td>Returns a <code>const_reverse_iterator1</code> pointing to the beginning of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_reverse_iterator1 rend1 () const</code></td> <td>Returns a <code>const_reverse_iterator1</code> pointing to the end of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>reverse_iterator1 rbegin1 ()</code> </td> <td>Returns a <code>reverse_iterator1</code> pointing to the beginning of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>reverse_iterator1 rend1 ()</code> </td> <td>Returns a <code>reverse_iterator1</code> pointing to the end of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_reverse_iterator2 rbegin2 () const</code></td> <td>Returns a <code>const_reverse_iterator2</code> pointing to the beginning of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>const_reverse_iterator2 rend2 () const</code></td> <td>Returns a <code>const_reverse_iterator2</code> pointing to the end of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>reverse_iterator2 rbegin2 ()</code> </td> <td>Returns a <code>reverse_iterator2</code> pointing to the beginning of the reversed <code>triangular_adaptor</code>.</td> </tr> <tr> <td><code>reverse_iterator2 rend2 ()</code> </td> <td>Returns a <code>reverse_iterator2</code> pointing to the end of the reversed <code>triangular_adaptor</code>.</td> </tr> </tbody> </table> <h4>Notes</h4> <p><a name="#triangular_adaptor_1">[1]</a> Supported parameters for the type of the triangular adaptor are <code>lower</code> , <code>unit_lower</code>, <code>upper</code> and <code>unit_upper</code> .</p> <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>