mirror of
https://github.com/boostorg/ublas.git
synced 2026-02-21 15:32:12 +00:00
* fix and close #2686
* replaced the word "upper" by "lower" because the description is for lower triangular matrices * added more detailed example for the use of triangular matrices and adaptors
This commit is contained in:
@@ -222,3 +222,7 @@ exe triangular_matrix
|
||||
exe triangular_adaptor
|
||||
: triangular_adaptor.cpp
|
||||
;
|
||||
|
||||
exe ex_triangular
|
||||
: ex_triangular.cpp
|
||||
;
|
||||
|
||||
58
doc/samples/ex_triangular.cpp
Normal file
58
doc/samples/ex_triangular.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright Gunter Winkler 2004 - 2009.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/numeric/ublas/matrix.hpp>
|
||||
#include <boost/numeric/ublas/triangular.hpp>
|
||||
|
||||
#include <boost/numeric/ublas/io.hpp>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
|
||||
|
||||
namespace ublas = boost::numeric::ublas;
|
||||
|
||||
|
||||
int main(int argc, char * argv[] ) {
|
||||
|
||||
ublas::matrix<double> M (3, 3);
|
||||
for (std::size_t i=0; i < M.data().size(); ++i) { M.data()[i] = 1+i ; }
|
||||
|
||||
std::cout << "full M = " << M << "\n" ;
|
||||
|
||||
ublas::triangular_matrix<double, ublas::lower> L;
|
||||
ublas::triangular_matrix<double, ublas::unit_lower> UL;
|
||||
ublas::triangular_matrix<double, ublas::strict_lower> SL;
|
||||
|
||||
L = ublas::triangular_adaptor<ublas::matrix<double>, ublas::lower> (M);
|
||||
SL = ublas::triangular_adaptor<ublas::matrix<double>, ublas::strict_lower> (M);
|
||||
UL = ublas::triangular_adaptor<ublas::matrix<double>, ublas::unit_lower> (M);
|
||||
|
||||
std::cout << "lower L = " << L << "\n"
|
||||
<< "strict lower SL = " << SL << "\n"
|
||||
<< "unit lower UL = " << UL << "\n" ;
|
||||
|
||||
ublas::triangular_matrix<double, ublas::upper> U;
|
||||
ublas::triangular_matrix<double, ublas::unit_upper> UU;
|
||||
ublas::triangular_matrix<double, ublas::strict_upper> SU;
|
||||
|
||||
U = ublas::triangular_adaptor<ublas::matrix<double>, ublas::upper> (M);
|
||||
SU = ublas::triangular_adaptor<ublas::matrix<double>, ublas::strict_upper> (M);
|
||||
UU = ublas::triangular_adaptor<ublas::matrix<double>, ublas::unit_upper> (M);
|
||||
|
||||
std::cout << "upper U = " << U << "\n"
|
||||
<< "strict upper SU = " << SU << "\n"
|
||||
<< "unit upper UU = " << UU << "\n" ;
|
||||
|
||||
std::cout << "M = L + SU ? " << ((norm_inf( M - (L + SU) ) == 0.0)?"ok":"failed") << "\n";
|
||||
std::cout << "M = U + SL ? " << ((norm_inf( M - (U + SL) ) == 0.0)?"ok":"failed") << "\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ For a <em>(n x n</em> )-dimensional lower triangular matrix and
|
||||
<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 <
|
||||
)-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
|
||||
@@ -46,6 +46,8 @@ int main () {
|
||||
std::cout << mu << std::endl;
|
||||
}
|
||||
</pre>
|
||||
<p>Please read the <a href="samples/ex_triangular.cpp">full triangular example</a> for more details.</p>
|
||||
|
||||
<h4>Definition</h4>
|
||||
<p>Defined in the header triangular.hpp.</p>
|
||||
<h4>Template parameters</h4>
|
||||
@@ -348,6 +350,8 @@ int main () {
|
||||
std::cout << tau << std::endl;
|
||||
}
|
||||
</pre>
|
||||
<p>Please read the <a href="samples/ex_triangular.cpp">full triangular example</a> for more details.</p>
|
||||
|
||||
<h4>Definition</h4>
|
||||
<p>Defined in the header triangular.hpp.</p>
|
||||
<h4>Template parameters</h4>
|
||||
|
||||
Reference in New Issue
Block a user