Hello community, here is the log from the commit of package armadillo for openSUSE:Factory checked in at 2015-05-27 12:52:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/armadillo (Old) and /work/SRC/openSUSE:Factory/.armadillo.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "armadillo" Changes: -------- --- /work/SRC/openSUSE:Factory/armadillo/armadillo.changes 2015-05-16 07:14:36.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.armadillo.new/armadillo.changes 2015-05-27 12:52:27.000000000 +0200 @@ -1,0 +2,10 @@ +Mon May 25 23:22:57 UTC 2015 - [email protected] + +- Update to version 5.200 (Boston Tea Smuggler): + + Added orth() for finding the orthonormal basis of the range + space of a matrix. + + Expanded element initialisation to handle nested initialiser + lists (C++11). + + Workarounds for bugs in GCC, Intel and MSVC C++ compilers. + +------------------------------------------------------------------- Old: ---- armadillo-5.100.2.tar.gz New: ---- armadillo-5.200.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ armadillo.spec ++++++ --- /var/tmp/diff_new_pack.TAiC7b/_old 2015-05-27 12:52:28.000000000 +0200 +++ /var/tmp/diff_new_pack.TAiC7b/_new 2015-05-27 12:52:28.000000000 +0200 @@ -19,7 +19,7 @@ %define soname libarmadillo5 Name: armadillo -Version: 5.100.2 +Version: 5.200.1 Release: 0 Summary: Fast C++ matrix library with interfaces to LAPACK and ATLAS License: MPL-2.0 ++++++ armadillo-5.100.2.tar.gz -> armadillo-5.200.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/CMakeLists.txt new/armadillo-5.200.1/CMakeLists.txt --- old/armadillo-5.100.2/CMakeLists.txt 2015-05-09 05:44:43.000000000 +0200 +++ new/armadillo-5.200.1/CMakeLists.txt 2015-05-24 05:52:32.000000000 +0200 @@ -13,8 +13,8 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR) set(ARMA_MAJOR 5) -set(ARMA_MINOR 100) -set(ARMA_PATCH 2) +set(ARMA_MINOR 200) +set(ARMA_PATCH 1) set(ARMADILLO_VERSION ${ARMA_MAJOR}.${ARMA_MINOR}.${ARMA_PATCH}) message(STATUS "Configuring Armadillo ${ARMADILLO_VERSION}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/README.txt new/armadillo-5.200.1/README.txt --- old/armadillo-5.100.2/README.txt 2015-05-09 05:44:43.000000000 +0200 +++ new/armadillo-5.200.1/README.txt 2015-05-24 05:52:32.000000000 +0200 @@ -192,7 +192,7 @@ If you want to use Armadillo without installation, or you're getting linking errors, compile along these lines: - g++ example1.cpp -o example1 -O2 -I /home/blah/armadillo-5.100.2/include -DARMA_DONT_USE_WRAPPER -lblas -llapack + g++ example1.cpp -o example1 -O2 -I /home/blah/armadillo-5.200.1/include -DARMA_DONT_USE_WRAPPER -lblas -llapack The above command line assumes that you have unpacked the armadillo archive into /home/blah/ You will need to adjust this for later versions of Armadillo, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/docs.html new/armadillo-5.200.1/docs.html --- old/armadillo-5.100.2/docs.html 2015-05-01 04:54:42.000000000 +0200 +++ new/armadillo-5.200.1/docs.html 2015-05-23 15:41:56.000000000 +0200 @@ -127,7 +127,7 @@ <tbody> <tr> <td style="text-align: left; vertical-align: top;"> - <font size=+2><b>Reference for Armadillo 5.100</b></font> + <font size=+2><b>Reference for Armadillo 5.200</b></font> <br> </td> <td style="text-align: right; vertical-align: top;"> @@ -402,16 +402,17 @@ <tr style="background-color: #F5F5F5;"><td><a href="#inv">inv</a></td><td> </td><td>inverse of general square matrix</td></tr> <tr><td><a href="#inv_sympd">inv_sympd</a></td><td> </td><td>inverse of symmetric positive definite matrix</td></tr> <tr><td><a href="#lu">lu </a></td><td> </td><td>lower-upper decomposition</td></tr> -<tr><td><a href="#pinv">pinv</a></td><td> </td><td>pseudo-inverse</td></tr> +<tr><td><a href="#orth">orth</a></td><td> </td><td>orthonormal basis of range space</td></tr> +<tr style="background-color: #F5F5F5;"><td><a href="#pinv">pinv</a></td><td> </td><td>pseudo-inverse</td></tr> <tr style="background-color: #F5F5F5;"><td><a href="#princomp">princomp</a></td><td> </td><td>principal component analysis</td></tr> <tr style="background-color: #F5F5F5;"><td><a href="#qr">qr </a></td><td> </td><td>QR decomposition</td></tr> -<tr style="background-color: #F5F5F5;"><td><a href="#qr_econ">qr_econ</a></td><td> </td><td>economical QR decomposition</td></tr> +<tr><td><a href="#qr_econ">qr_econ</a></td><td> </td><td>economical QR decomposition</td></tr> <tr><td><a href="#solve">solve</a></td><td> </td><td>solve systems of linear equations</td></tr> <tr><td><a href="#spsolve">spsolve</a></td><td> </td><td>solve sparse systems of linear equations</td></tr> -<tr><td><a href="#svd">svd</a></td><td> </td><td>singular value decomposition</td></tr> +<tr style="background-color: #F5F5F5;"><td><a href="#svd">svd</a></td><td> </td><td>singular value decomposition</td></tr> <tr style="background-color: #F5F5F5;"><td><a href="#svd_econ">svd_econ</a></td><td> </td><td>economical singular value decomposition</td></tr> <tr style="background-color: #F5F5F5;"><td><a href="#svds">svds</a></td><td> </td><td>limited number of singular values & singular vectors of sparse matrix</td></tr> -<tr style="background-color: #F5F5F5;"><td><a href="#syl">syl</a></td><td> </td><td>Sylvester equation solver</td></tr> +<tr><td><a href="#syl">syl</a></td><td> </td><td>Sylvester equation solver</td></tr> </tbody> </table> </ul> @@ -2089,7 +2090,7 @@ For <i>vec</i> and <i>rowvec</i>, access the <i>n</i>-th element. For <i>mat</i>, <i>cube</i> and <i>field</i>, access the <i>n</i>-th element/object under the assumption of a flat layout, with column-major ordering of data (ie. column by column). -A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds. +A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds. The bounds check can be <a href="#element_access_bounds_check_note">optionally disabled</a> at compile-time to get more speed. </td> </tr> @@ -2122,7 +2123,7 @@ </td> <td style="vertical-align: top;"> For <i>mat</i> and <i>field</i> classes, access the element/object stored at the <i>i</i>-th row and <i>j</i>-th column. -A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds. +A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds. The bounds check can be <a href="#element_access_bounds_check_note">optionally disabled</a> at compile-time to get more speed. </td> </tr> @@ -2157,7 +2158,7 @@ </td> <td style="vertical-align: top;"> Cube only: access the element stored at the <i>i</i>-th row, <i>j</i>-th column and <i>k</i>-th slice. -A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds. +A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds. The bounds check can be <a href="#element_access_bounds_check_note">optionally disabled</a> at compile-time to get more speed. </td> </tr> @@ -2261,8 +2262,10 @@ A << 1 << 3 << 5 << endr << 2 << 4 << 6 << endr; -mat B = { 1, 2, 3, 4, 5, 6 }; // C++11 only +mat B = { 1, 2, 3, 4, 5, 6 }; // C++11 only B.reshape(2,3); + +mat C = { {1, 3, 5}, {2, 4, 6} }; // C++11 only (version 5.200+) </pre> </ul> </li> @@ -6484,6 +6487,10 @@ </li> <br> <li> +The computation is based on singular value decomposition; if the decomposition fails, a <i>std::runtime_error</i> exception is thrown +</li> +<br> +<li> Examples: <ul> <pre> @@ -7923,11 +7930,15 @@ <ul> <li>Returns the rank of matrix <i>X</i></li> <br> -<li>Any singular values less than default tolerance are treated as zero</li> +<li>Any singular values less than <i>tolerance</i> are treated as zero</li> <br> -<li>The <i>tolerance</i> argument is optional; -by default the tolerance is <i>max(X.n_rows, X.n_cols)*eps(sigma)</i>, -where <i>sigma</i> is the largest singular value of <i>X</i> +<li> +The <i>tolerance</i> argument is optional; by default <i>tolerance</i> is <i>max(m,n)*max_sv*datum::eps</i>, where: +<ul> +<li><i>m</i> = number of rows and <i>n</i> = number of columns in <i>X</i></li> +<li><i>max_sv</i> = maximal singular value of <i>X</i></li> +<li><i>datum::eps</i> = difference between 1 and the least value greater than 1 that is representable</li> +</ul> </li> <br> <li>The computation is based on singular value decomposition; @@ -7948,7 +7959,9 @@ See also: <ul> <li><a href="#cond">cond()</a></li> -<li><a href="#eps">eps()</a></li> +<li><a href="#svd">svd()</a></li> +<li><a href="#orth">orth()</a></li> +<li><a href="#constants">datum::eps</a></li> <li><a href="http://mathworld.wolfram.com/MatrixRank.html">Rank in MathWorld</a></li> <li><a href="http://en.wikipedia.org/wiki/Rank_(linear_algebra)">Rank in Wikipedia</a></li> </ul> @@ -9031,6 +9044,8 @@ <li> See also: <ul> +<li><a href="#lu">lu()</a></li> +<li><a href="#qr">qr()</a></li> <li><a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">Cholesky decomposition in MathWorld</a></li> <li><a href="http://en.wikipedia.org/wiki/Cholesky_decomposition">Cholesky decomposition in Wikipedia</a></li> </ul> @@ -9286,7 +9301,7 @@ <ul> <pre> // generate sparse matrix -sp_mat A = sprandu<mat>(1000, 1000, 0.1); +sp_mat A = sprandu<sp_mat>(1000, 1000, 0.1); sp_mat B = A.t()*A; vec eigval; @@ -9675,6 +9690,7 @@ <li> See also: <ul> +<li><a href="#chol">chol()</a></li> <li><a href="http://en.wikipedia.org/wiki/LU_decomposition">LU decomposition in Wikipedia</a></li> <li><a href="http://mathworld.wolfram.com/LUDecomposition.html">LU decomposition in MathWorld</a></li> </ul> @@ -9683,6 +9699,64 @@ </ul> <hr class="greyline"><br> +<a name="orth"></a> +<b>B = orth( A )</b> +<br><b>B = orth( A, tolerance )</b> +<br> +<br><b>orth( B, A )</b> +<br><b>orth( B, A, tolerance )</b> +<ul> +<li> +Find the orthonormal basis of the range space of matrix <i>A</i>, +so that <i>B.t()*B ≈ eye(r,r)</i>, where <i>r = rank(A)</i> +</li> +<br> +<li> +The dimension of the range space is the number of singular values of <i>A</i> greater than <i>tolerance</i> +</li> +<br> +<li> +The <i>tolerance</i> argument is optional; by default <i>tolerance</i> is <i>max(m,n)*max_sv*datum::eps</i>, where: +<ul> +<li><i>m</i> = number of rows and <i>n</i> = number of columns in <i>A</i></li> +<li><i>max_sv</i> = maximal singular value of <i>A</i></li> +<li><i>datum::eps</i> = difference between 1 and the least value greater than 1 that is representable</li> +</ul> +</li> +<br> +<li> +The computation is based on singular value decomposition; if the decomposition fails: +<ul> +<li><i>B = orth(A)</i> resets <i>B</i> and throws a <i>std::runtime_error</i> exception</li> +<li><i>orth(B,A)</i> resets <i>B</i> and returns a bool set to <i>false</i> (exception is not thrown)</li> +</ul> +</li> +<br> +<li> +Examples: +<ul> +<pre> +mat A = randu<mat>(5,6); + +mat B = orth(A); +</pre> +</ul> +</li> +<br> +<li> +See also: +<ul> +<li><a href="#qr">qr()</a></li> +<li><a href="#svd">svd()</a></li> +<li><a href="#rank">rank()</a></li> +<li><a href="#constants">datum::eps</a></li> +<li><a href="http://en.wikipedia.org/wiki/Orthonormal_basis">Orthonormal basis in Wikipedia</a></li> +</ul> +</li> +<br> +</ul> +<hr class="greyline"><br> + <a name="pinv"></a> <b>B = pinv( A )</b> <br><b>B = pinv( A, tolerance )</b> @@ -9856,10 +9930,11 @@ See also: <ul> <li><a href="#qr_econ">qr_econ()</a></li> +<li><a href="#chol">chol()</a></li> +<li><a href="#orth">orth()</a></li> <li><a href="http://en.wikipedia.org/wiki/Orthogonal_matrix">orthogonal matrix in Wikipedia</a></li> <li><a href="http://en.wikipedia.org/wiki/QR_decomposition">QR decomposition in Wikipedia</a></li> <li><a href="http://mathworld.wolfram.com/QRDecomposition.html">QR decomposition in MathWorld</a></li> -<li><a href="http://octave.sourceforge.net/octave/function/qr.html">QR decomposition in Octave</a></li> </ul> </li> <br> @@ -13754,6 +13829,14 @@ <br> <ul> +<a name="version_5200"></a> +<li>Version 5.200: +<ul> +<li>added <a href="#orth">orth()</a> for finding the orthonormal basis of the range space of a matrix</li> +<li>expanded <a href="#element_initialisation">element initialisation</a> to handle nested initialiser lists (C++11)</li> +</ul> +</li> +<br> <a name="version_5100"></a> <li>Version 5.100: <ul> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/arma_rng.hpp new/armadillo-5.200.1/include/armadillo_bits/arma_rng.hpp --- old/armadillo-5.100.2/include/armadillo_bits/arma_rng.hpp 2015-02-13 08:35:58.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/arma_rng.hpp 2015-05-24 05:57:31.000000000 +0200 @@ -87,7 +87,7 @@ seed_type seed4 = seed_type(0); seed_type seed5 = seed_type(0); - bool rd_ok = false; + bool have_seed = false; #if defined(ARMA_USE_CXX11) { @@ -95,28 +95,44 @@ { std::random_device rd; - seed1 = static_cast<seed_type>( rd() ); + if(rd.entropy() > double(0)) { seed1 = static_cast<seed_type>( rd() ); } - rd_ok = true; + if(seed1 != seed_type(0)) { have_seed = true; } } catch(...) {} } #endif - if(rd_ok == false) + + if(have_seed == false) { try { - unsigned char buffer = 0; + union + { + seed_type a; + unsigned char b[sizeof(seed_type)]; + } tmp; + + tmp.a = seed_type(0); std::ifstream f("/dev/urandom", std::ifstream::binary); - f.read((char*)(&buffer), 1); + if(f.good()) { f.read((char*)(&(tmp.b[0])), sizeof(seed_type)); } - seed2 = static_cast<seed_type>(buffer); + if(f.good()) + { + seed2 = tmp.a; + + if(seed2 != seed_type(0)) { have_seed = true; } + } } catch(...) {} - + } + + + if(have_seed == false) + { // get better-than-nothing seeds in case reading /dev/urandom failed #if defined(ARMA_HAVE_GETTIMEOFDAY) @@ -135,13 +151,16 @@ { uword* a; unsigned char b[sizeof(uword*)]; - } address; - - uword junk = 0; + } tmp; - address.a = &junk; + tmp.a = (uword*)malloc(sizeof(uword)); - seed5 = seed_type(address.b[0]) + seed_type(address.b[sizeof(uword*)-1]); + if(tmp.a != NULL) + { + for(size_t i=0; i<sizeof(uword*); ++i) { seed5 += seed_type(tmp.b[i]); } + + free(tmp.a); + } } arma_rng::set_seed( seed1 + seed2 + seed3 + seed4 + seed5 ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/arma_version.hpp new/armadillo-5.200.1/include/armadillo_bits/arma_version.hpp --- old/armadillo-5.100.2/include/armadillo_bits/arma_version.hpp 2015-05-09 05:44:43.000000000 +0200 +++ new/armadillo-5.200.1/include/armadillo_bits/arma_version.hpp 2015-05-24 05:52:32.000000000 +0200 @@ -12,9 +12,9 @@ #define ARMA_VERSION_MAJOR 5 -#define ARMA_VERSION_MINOR 100 -#define ARMA_VERSION_PATCH 2 -#define ARMA_VERSION_NAME "Ankle Biter Deluxe" +#define ARMA_VERSION_MINOR 200 +#define ARMA_VERSION_PATCH 1 +#define ARMA_VERSION_NAME "Boston Tea Smuggler" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/cond_rel_bones.hpp new/armadillo-5.200.1/include/armadillo_bits/cond_rel_bones.hpp --- old/armadillo-5.100.2/include/armadillo_bits/cond_rel_bones.hpp 2013-02-21 08:16:35.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/cond_rel_bones.hpp 2015-05-18 03:57:02.000000000 +0200 @@ -23,6 +23,8 @@ template<typename eT> arma_inline static bool leq(const eT A, const eT B); template<typename eT> arma_inline static bool geq(const eT A, const eT B); + + template<typename eT> arma_inline static eT make_neg(const eT val); }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/cond_rel_meat.hpp new/armadillo-5.200.1/include/armadillo_bits/cond_rel_meat.hpp --- old/armadillo-5.100.2/include/armadillo_bits/cond_rel_meat.hpp 2013-02-21 08:16:35.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/cond_rel_meat.hpp 2015-05-18 03:57:02.000000000 +0200 @@ -96,6 +96,28 @@ { return false; } + + + +template<> +template<typename eT> +arma_inline +eT +cond_rel<true>::make_neg(const eT val) + { + return -val; + } + + + +template<> +template<typename eT> +arma_inline +eT +cond_rel<false>::make_neg(const eT) + { + return eT(0); + } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/diskio_meat.hpp new/armadillo-5.200.1/include/armadillo_bits/diskio_meat.hpp --- old/armadillo-5.100.2/include/armadillo_bits/diskio_meat.hpp 2015-04-09 18:04:04.000000000 +0200 +++ new/armadillo-5.200.1/include/armadillo_bits/diskio_meat.hpp 2015-05-18 04:05:37.000000000 +0200 @@ -784,14 +784,14 @@ if( (token2 == "inf") || (token2 == "Inf") || (token2 == "INF") ) { - val = neg ? -(Datum<eT>::inf) : Datum<eT>::inf; + val = neg ? cond_rel< is_signed<eT>::value >::make_neg(Datum<eT>::inf) : Datum<eT>::inf; return true; } else if( (token2 == "nan") || (token2 == "Nan") || (token2 == "NaN") || (token2 == "NAN") ) { - val = neg ? -(Datum<eT>::nan) : Datum<eT>::nan; + val = Datum<eT>::nan; return true; } @@ -1458,24 +1458,31 @@ { f >> token; - ss.clear(); - ss.str(token); - - eT val = eT(0); - ss >> val; - - if(ss.fail() == false) + if( (is_signed<eT>::value == false) && (token.length() > 0) && (token[0] == '-') ) { - x.at(row,col) = val; + x.at(row,col) = eT(0); } else { - const bool success = diskio::convert_naninf( x.at(row,col), token ); + ss.clear(); + ss.str(token); + + eT val = eT(0); + ss >> val; - if(success == false) + if(ss.fail() == false) + { + x.at(row,col) = val; + } + else { - load_okay = false; - err_msg = "couldn't interpret data in "; + const bool success = diskio::convert_naninf( x.at(row,col), token ); + + if(success == false) + { + load_okay = false; + err_msg = "couldn't interpret data in "; + } } } } @@ -1776,19 +1783,26 @@ { std::getline(line_stream, token, ','); - ss.clear(); - ss.str(token); - - eT val = eT(0); - ss >> val; - - if(ss.fail() == false) + if( (is_signed<eT>::value == false) && (token.length() > 0) && (token[0] == '-') ) { - x.at(row,col) = val; + x.at(row,col) = eT(0); } else { - diskio::convert_naninf( x.at(row,col), token ); + ss.clear(); + ss.str(token); + + eT val = eT(0); + ss >> val; + + if(ss.fail() == false) + { + x.at(row,col) = val; + } + else + { + diskio::convert_naninf( x.at(row,col), token ); + } } ++col; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/fn_misc.hpp new/armadillo-5.200.1/include/armadillo_bits/fn_misc.hpp --- old/armadillo-5.100.2/include/armadillo_bits/fn_misc.hpp 2015-02-02 16:02:28.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/fn_misc.hpp 2015-05-21 05:42:55.000000000 +0200 @@ -297,4 +297,34 @@ +template<typename T1> +arma_inline +const Op<T1, op_orth> +orth(const Base<typename T1::elem_type, T1>& X, const typename T1::pod_type tol = 0.0, const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0) + { + arma_extra_debug_sigprint(); + arma_ignore(junk); + + typedef typename T1::elem_type eT; + + return Op<T1, op_orth>(X.get_ref(), eT(tol)); + } + + + +template<typename T1> +inline +bool +orth(Mat<typename T1::elem_type>& out, const Base<typename T1::elem_type, T1>& X, const typename T1::pod_type tol = 0.0, const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0) + { + arma_extra_debug_sigprint(); + arma_ignore(junk); + + try { out = orth(X,tol); } catch (std::runtime_error&) { return false; } + + return true; + } + + + //! @} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/fn_rank.hpp new/armadillo-5.200.1/include/armadillo_bits/fn_rank.hpp --- old/armadillo-5.100.2/include/armadillo_bits/fn_rank.hpp 2013-12-10 15:47:25.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/fn_rank.hpp 2015-05-20 16:53:22.000000000 +0200 @@ -1,5 +1,5 @@ -// Copyright (C) 2009-2013 Conrad Sanderson -// Copyright (C) 2009-2013 NICTA (www.nicta.com.au) +// Copyright (C) 2009-2015 Conrad Sanderson +// Copyright (C) 2009-2015 NICTA (www.nicta.com.au) // Copyright (C) 2009-2010 Dimitrios Bouzas // Copyright (C) 2011 Stanislav Funiak // @@ -33,35 +33,29 @@ uword X_n_cols; Col<T> s; - const bool status = auxlib::svd_dc(s, X, X_n_rows, X_n_cols); - const uword n_elem = s.n_elem; + const bool status = auxlib::svd_dc(s, X, X_n_rows, X_n_cols); - if(status == true) - { - if( (tol == T(0)) && (n_elem > 0) ) - { - tol = (std::max)(X_n_rows, X_n_cols) * eop_aux::direct_eps(max(s)); - } - - // count non zero valued elements in s - - const T* s_mem = s.memptr(); - - uword count = 0; - - for(uword i=0; i<n_elem; ++i) - { - if(s_mem[i] > tol) { ++count; } - } - - return count; - } - else + if(status == false) { arma_bad("rank(): failed to converge"); return uword(0); } + + const uword s_n_elem = s.n_elem; + const T* s_mem = s.memptr(); + + // set tolerance to default if it hasn't been specified + if( (tol == T(0)) && (s_n_elem > 0) ) + { + tol = (std::max)(X_n_rows, X_n_cols) * s_mem[0] * std::numeric_limits<T>::epsilon(); + } + + uword count = 0; + + for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1) : uword(0); } + + return count; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/op_misc_bones.hpp new/armadillo-5.200.1/include/armadillo_bits/op_misc_bones.hpp --- old/armadillo-5.100.2/include/armadillo_bits/op_misc_bones.hpp 2014-01-04 18:52:16.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/op_misc_bones.hpp 2015-05-20 16:36:21.000000000 +0200 @@ -1,5 +1,5 @@ -// Copyright (C) 2008-2011 Conrad Sanderson -// Copyright (C) 2008-2011 NICTA (www.nicta.com.au) +// Copyright (C) 2008-2015 Conrad Sanderson +// Copyright (C) 2008-2015 NICTA (www.nicta.com.au) // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -49,5 +49,15 @@ }; + +class op_orth + { + public: + + template<typename T1> + inline static void apply(Mat<typename T1::elem_type>& out, const Op<T1, op_orth>& expr); + }; + + //! @} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-5.100.2/include/armadillo_bits/op_misc_meat.hpp new/armadillo-5.200.1/include/armadillo_bits/op_misc_meat.hpp --- old/armadillo-5.100.2/include/armadillo_bits/op_misc_meat.hpp 2014-01-04 18:52:16.000000000 +0100 +++ new/armadillo-5.200.1/include/armadillo_bits/op_misc_meat.hpp 2015-05-21 10:16:51.000000000 +0200 @@ -1,5 +1,5 @@ -// Copyright (C) 2008-2012 Conrad Sanderson -// Copyright (C) 2008-2012 NICTA (www.nicta.com.au) +// Copyright (C) 2008-2015 Conrad Sanderson +// Copyright (C) 2008-2015 NICTA (www.nicta.com.au) // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -273,6 +273,59 @@ } } + + +template<typename T1> +inline +void +op_orth::apply( Mat<typename T1::elem_type>& out, const Op<T1, op_orth>& expr ) + { + arma_extra_debug_sigprint(); + + typedef typename T1::elem_type eT; + typedef typename T1::pod_type T; + + T tol = access::tmp_real(expr.aux); + + arma_debug_check((tol < T(0)), "orth(): tolerance must be >= 0"); + + const unwrap<T1> tmp(expr.m); + const Mat<eT>& X = tmp.M; + + Mat<eT> U; + Col< T> s; + Mat<eT> V; + + //const bool status = auxlib::svd_econ(U, s, V, X, 'l'); + //const bool status = auxlib::svd_dc(U, s, V, X); + const bool status = auxlib::svd_dc_econ(U, s, V, X); + + V.reset(); + + if(status == false) { out.reset(); arma_bad("orth(): svd failed"); return; } + + if(s.is_empty()) { out.reset(); return; } + + const uword s_n_elem = s.n_elem; + const T* s_mem = s.memptr(); + + // set tolerance to default if it hasn't been specified + if(tol == T(0)) { tol = (std::max)(X.n_rows, X.n_cols) * s_mem[0] * std::numeric_limits<T>::epsilon(); } + + uword count = 0; + + for(uword i=0; i < s_n_elem; ++i) { count += (s_mem[i] > tol) ? uword(1) : uword(0); } + + if(count > 0) + { + out = U.head_cols(count); // out *= eT(-1); + } + else + { + out.set_size(X.n_rows, 0); + } + } + //! @}
