Hello community, here is the log from the commit of package armadillo for openSUSE:Factory checked in at 2014-10-11 19:26:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2014-09-19 15:45:45.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.armadillo.new/armadillo.changes 2014-10-11 19:27:27.000000000 +0200 @@ -1,0 +2,12 @@ +Thu Oct 9 19:04:57 UTC 2014 - badshah...@gmail.com + +- Update to version 4.450.3: + + No list of changes documented upstream. + +------------------------------------------------------------------- +Fri Oct 3 06:21:56 UTC 2014 - badshah...@gmail.com + +- Update to version 4.450.2: + + No list of changes documented upstream. + +------------------------------------------------------------------- Old: ---- armadillo-4.450.0.tar.gz New: ---- armadillo-4.450.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ armadillo.spec ++++++ --- /var/tmp/diff_new_pack.qeEJC0/_old 2014-10-11 19:27:28.000000000 +0200 +++ /var/tmp/diff_new_pack.qeEJC0/_new 2014-10-11 19:27:28.000000000 +0200 @@ -19,7 +19,7 @@ %define soname libarmadillo4 Name: armadillo -Version: 4.450.0 +Version: 4.450.3 Release: 0 Summary: Fast C++ matrix library with interfaces to LAPACK and ATLAS License: MPL-2.0 ++++++ armadillo-4.450.0.tar.gz -> armadillo-4.450.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/CMakeLists.txt new/armadillo-4.450.3/CMakeLists.txt --- old/armadillo-4.450.0/CMakeLists.txt 2014-09-18 11:08:43.000000000 +0200 +++ new/armadillo-4.450.3/CMakeLists.txt 2014-10-07 16:03:47.000000000 +0200 @@ -14,7 +14,7 @@ set(ARMA_MAJOR 4) set(ARMA_MINOR 450) -set(ARMA_PATCH 0) +set(ARMA_PATCH 3) 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-4.450.0/README.txt new/armadillo-4.450.3/README.txt --- old/armadillo-4.450.0/README.txt 2014-09-19 04:18:06.000000000 +0200 +++ new/armadillo-4.450.3/README.txt 2014-10-07 16:03:47.000000000 +0200 @@ -187,10 +187,10 @@ 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-4.450.0/include -DARMA_USE_BLAS -DARMA_USE_LAPACK -DARMA_DONT_USE_WRAPPER -lblas -llapack + g++ example1.cpp -o example1 -O2 -I /home/blah/armadillo-4.450.3/include -DARMA_USE_BLAS -DARMA_USE_LAPACK -DARMA_DONT_USE_WRAPPER -lblas -llapack The above command line assumes that you have unpacked the armadillo archive -(armadillo-4.450.0.tar.gz in this case) into /home/blah/ +(armadillo-4.450.3.tar.gz in this case) into /home/blah/ You will need to adjust this for later versions of Armadillo, and/or if you have unpacked into a different directory. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/docs.html new/armadillo-4.450.3/docs.html --- old/armadillo-4.450.0/docs.html 2014-09-18 11:11:26.000000000 +0200 +++ new/armadillo-4.450.3/docs.html 2014-09-30 18:16:47.000000000 +0200 @@ -229,7 +229,6 @@ <a href="#operators">operators</a> · <a href="#print">print</a> · <a href="#raw_print">raw_print</a> · -<a href="#randi">randi</a> · <a href="#randu_randn_member">randu/randn</a> · <a href="#reset">reset</a> · <a href="#reshape_member">reshape</a> · @@ -256,6 +255,7 @@ <a href="#eye_standalone">eye</a> · <a href="#linspace">linspace</a> · <a href="#ones_standalone">ones</a> · +<a href="#randi">randi</a> · <a href="#randu_randn_standalone">randu/randn</a> · <a href="#repmat">repmat</a> · <a href="#speye">speye</a> · diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo new/armadillo-4.450.3/include/armadillo --- old/armadillo-4.450.0/include/armadillo 2014-08-28 08:44:26.000000000 +0200 +++ new/armadillo-4.450.3/include/armadillo 2014-09-21 05:46:47.000000000 +0200 @@ -112,10 +112,13 @@ #include "armadillo_bits/constants.hpp" #include "armadillo_bits/constants_compat.hpp" - #if defined(ARMA_USE_CXX11_RNG) + #ifdef ARMA_RNG_ALT + #include ARMA_INCFILE_WRAP(ARMA_RNG_ALT) + #include "armadillo_bits/arma_rng.hpp" + #elif defined(ARMA_USE_CXX11_RNG) #include "armadillo_bits/arma_rng_cxx11.hpp" #include "armadillo_bits/arma_rng.hpp" - #else + #else #include "armadillo_bits/arma_rng_cxx98.hpp" #include "armadillo_bits/arma_rng.hpp" #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo_bits/Mat_meat.hpp new/armadillo-4.450.3/include/armadillo_bits/Mat_meat.hpp --- old/armadillo-4.450.0/include/armadillo_bits/Mat_meat.hpp 2014-08-28 06:39:31.000000000 +0200 +++ new/armadillo-4.450.3/include/armadillo_bits/Mat_meat.hpp 2014-09-30 06:36:41.000000000 +0200 @@ -6463,11 +6463,11 @@ template<typename eT> inline -Mat<eT>::row_col_iterator::row_col_iterator(Mat<eT>& in_M, const uword row, const uword col) - : M (&in_M ) - , current_pos (&in_M.at(row,col)) - , internal_col(col ) - , internal_row(row ) +Mat<eT>::row_col_iterator::row_col_iterator(Mat<eT>& in_M, const uword in_row, const uword in_col) + : M (&in_M ) + , current_pos (&in_M.at(in_row,in_col)) + , internal_col(in_col ) + , internal_row(in_row ) { arma_extra_debug_sigprint(); } @@ -6656,11 +6656,11 @@ template<typename eT> inline -Mat<eT>::const_row_col_iterator::const_row_col_iterator(const Mat<eT>& in_M, const uword row, const uword col) - : M (&in_M ) - , current_pos (&in_M.at(row,col)) - , internal_col(col ) - , internal_row(row ) +Mat<eT>::const_row_col_iterator::const_row_col_iterator(const Mat<eT>& in_M, const uword in_row, const uword in_col) + : M (&in_M ) + , current_pos (&in_M.at(in_row,in_col)) + , internal_col(in_col ) + , internal_row(in_row ) { arma_extra_debug_sigprint(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo_bits/arma_rng.hpp new/armadillo-4.450.3/include/armadillo_bits/arma_rng.hpp --- old/armadillo-4.450.0/include/armadillo_bits/arma_rng.hpp 2013-12-01 13:52:27.000000000 +0100 +++ new/armadillo-4.450.3/include/armadillo_bits/arma_rng.hpp 2014-10-07 16:03:25.000000000 +0200 @@ -1,5 +1,5 @@ -// Copyright (C) 2013 Conrad Sanderson -// Copyright (C) 2013 NICTA (www.nicta.com.au) +// Copyright (C) 2013-2014 Conrad Sanderson +// Copyright (C) 2013-2014 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 @@ -10,6 +10,10 @@ //! @{ +#if defined(ARMA_RNG_ALT) + #undef ARMA_USE_CXX11_RNG +#endif + #if defined(ARMA_USE_CXX11_RNG) extern thread_local arma_rng_cxx11 arma_rng_cxx11_instance; @@ -21,13 +25,17 @@ { public: - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + typedef arma_rng_alt::seed_type seed_type; + #elif defined(ARMA_USE_CXX11_RNG) typedef arma_rng_cxx11::seed_type seed_type; #else typedef arma_rng_cxx98::seed_type seed_type; #endif - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + static const int rng_method = 2; + #elif defined(ARMA_USE_CXX11_RNG) static const int rng_method = 1; #else static const int rng_method = 0; @@ -47,7 +55,11 @@ void arma_rng::set_seed(const arma_rng::seed_type val) { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + arma_rng_alt::set_seed(val); + } + #elif defined(ARMA_USE_CXX11_RNG) { arma_rng_cxx11_instance.set_seed(val); } @@ -138,7 +150,11 @@ arma_inline operator eT () { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + return eT( arma_rng_alt::randi_val() ); + } + #elif defined(ARMA_USE_CXX11_RNG) { return eT( arma_rng_cxx11_instance.randi_val() ); } @@ -155,7 +171,11 @@ int max_val() { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + return arma_rng_alt::randi_max_val(); + } + #elif defined(ARMA_USE_CXX11_RNG) { return arma_rng_cxx11::randi_max_val(); } @@ -172,7 +192,11 @@ void fill(eT* mem, const uword N, const int a, const int b) { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + return arma_rng_alt::randi_fill(mem, N, a, b); + } + #elif defined(ARMA_USE_CXX11_RNG) { return arma_rng_cxx11_instance.randi_fill(mem, N, a, b); } @@ -192,7 +216,11 @@ arma_inline operator eT () { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + return eT( arma_rng_alt::randu_val() ); + } + #elif defined(ARMA_USE_CXX11_RNG) { return eT( arma_rng_cxx11_instance.randu_val() ); } @@ -235,7 +263,10 @@ arma_inline operator std::complex<T> () { - return std::complex<T>( T( arma_rng::randu<T>() ), T( arma_rng::randu<T>() ) ); + const T a = T( arma_rng::randu<T>() ); + const T b = T( arma_rng::randu<T>() ); + + return std::complex<T>(a, b); } @@ -246,7 +277,10 @@ { for(uword i=0; i < N; ++i) { - mem[i] = std::complex<T>( T( arma_rng::randu<T>() ), T( arma_rng::randu<T>() ) ); + const T a = T( arma_rng::randu<T>() ); + const T b = T( arma_rng::randu<T>() ); + + mem[i] = std::complex<T>(a, b); } } }; @@ -259,7 +293,11 @@ inline operator eT () const { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + return eT( arma_rng_alt::randn_val() ); + } + #elif defined(ARMA_USE_CXX11_RNG) { return eT( arma_rng_cxx11_instance.randn_val() ); } @@ -276,7 +314,11 @@ void dual_val(eT& out1, eT& out2) { - #if defined(ARMA_USE_CXX11_RNG) + #if defined(ARMA_RNG_ALT) + { + arma_rng_alt::randn_dual_val(out1, out2); + } + #elif defined(ARMA_USE_CXX11_RNG) { arma_rng_cxx11_instance.randn_dual_val(out1, out2); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo_bits/arma_rng_cxx98.hpp new/armadillo-4.450.3/include/armadillo_bits/arma_rng_cxx98.hpp --- old/armadillo-4.450.0/include/armadillo_bits/arma_rng_cxx98.hpp 2014-01-14 09:28:41.000000000 +0100 +++ new/armadillo-4.450.3/include/armadillo_bits/arma_rng_cxx98.hpp 2014-09-30 18:13:02.000000000 +0200 @@ -47,7 +47,20 @@ int arma_rng_cxx98::randi_val() { - return std::rand(); + #if (RAND_MAX == 32767) + { + u32 val1 = u32(std::rand()); + u32 val2 = u32(std::rand()); + + val1 <<= 15; + + return (val1 | val2); + } + #else + { + return std::rand(); + } + #endif } @@ -56,7 +69,7 @@ double arma_rng_cxx98::randu_val() { - return double( double(std::rand()) * ( double(1) / double(RAND_MAX) ) ); + return double( double(randi_val()) * ( double(1) / double(randi_max_val()) ) ); } @@ -75,8 +88,8 @@ do { - tmp1 = double(2) * double(std::rand()) * (double(1) / double(RAND_MAX)) - double(1); - tmp2 = double(2) * double(std::rand()) * (double(1) / double(RAND_MAX)) - double(1); + tmp1 = double(2) * double(randi_val()) * (double(1) / double(randi_max_val())) - double(1); + tmp2 = double(2) * double(randi_val()) * (double(1) / double(randi_max_val())) - double(1); w = tmp1*tmp1 + tmp2*tmp2; } @@ -101,8 +114,8 @@ do { - tmp1 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1); - tmp2 = eTp(2) * eTp(std::rand()) * (eTp(1) / eTp(RAND_MAX)) - eTp(1); + tmp1 = eTp(2) * eTp(randi_val()) * (eTp(1) / eTp(randi_max_val())) - eTp(1); + tmp2 = eTp(2) * eTp(randi_val()) * (eTp(1) / eTp(randi_max_val())) - eTp(1); w = tmp1*tmp1 + tmp2*tmp2; } @@ -132,11 +145,11 @@ { const uword length = b - a + 1; - const double scale = double(length) / double(RAND_MAX); + const double scale = double(length) / double(randi_max_val()); for(uword i=0; i<N; ++i) { - mem[i] = (std::min)( b, (int( double(std::rand()) * scale ) + a) ); + mem[i] = (std::min)( b, (int( double(randi_val()) * scale ) + a) ); } } } @@ -147,7 +160,11 @@ int arma_rng_cxx98::randi_max_val() { - return RAND_MAX; + #if (RAND_MAX == 32767) + return ( (32767 << 15) + 32767); + #else + return RAND_MAX; + #endif } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo_bits/arma_version.hpp new/armadillo-4.450.3/include/armadillo_bits/arma_version.hpp --- old/armadillo-4.450.0/include/armadillo_bits/arma_version.hpp 2014-09-18 11:08:43.000000000 +0200 +++ new/armadillo-4.450.3/include/armadillo_bits/arma_version.hpp 2014-10-07 16:03:47.000000000 +0200 @@ -13,7 +13,7 @@ #define ARMA_VERSION_MAJOR 4 #define ARMA_VERSION_MINOR 450 -#define ARMA_VERSION_PATCH 0 +#define ARMA_VERSION_PATCH 3 #define ARMA_VERSION_NAME "Spring Hill Fort" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo_bits/fn_norm.hpp new/armadillo-4.450.3/include/armadillo_bits/fn_norm.hpp --- old/armadillo-4.450.0/include/armadillo_bits/fn_norm.hpp 2014-05-19 17:20:03.000000000 +0200 +++ new/armadillo-4.450.3/include/armadillo_bits/fn_norm.hpp 2014-10-07 15:42:30.000000000 +0200 @@ -15,9 +15,14 @@ arma_hot inline typename T1::pod_type -arma_vec_norm_1(const Proxy<T1>& P) +arma_vec_norm_1 + ( + const Proxy<T1>& P, + const typename arma_not_cx<typename T1::elem_type>::result* junk = 0 + ) { arma_extra_debug_sigprint(); + arma_ignore(junk); typedef typename T1::pod_type T; @@ -60,24 +65,29 @@ } else { + T acc1 = T(0); + T acc2 = T(0); + for(uword col=0; col<n_cols; ++col) { uword i,j; for(i=0, j=1; j<n_rows; i+=2, j+=2) { - acc += std::abs(P.at(i,col)); - acc += std::abs(P.at(j,col)); + acc1 += std::abs(P.at(i,col)); + acc2 += std::abs(P.at(j,col)); } if(i < n_rows) { - acc += std::abs(P.at(i,col)); + acc1 += std::abs(P.at(i,col)); } } + + acc = acc1 + acc2; } } - + return acc; } @@ -87,6 +97,118 @@ arma_hot inline typename T1::pod_type +arma_vec_norm_1 + ( + const Proxy<T1>& P, + const typename arma_cx_only<typename T1::elem_type>::result* junk = 0 + ) + { + arma_extra_debug_sigprint(); + arma_ignore(junk); + + typedef typename T1::elem_type eT; + typedef typename T1::pod_type T; + + T acc = T(0); + + if(Proxy<T1>::prefer_at_accessor == false) + { + typename Proxy<T1>::ea_type A = P.get_ea(); + + const uword N = P.get_n_elem(); + + for(uword i=0; i<N; ++i) + { + const std::complex<T>& X = A[i]; + + const T a = X.real(); + const T b = X.imag(); + + acc += std::sqrt( (a*a) + (b*b) ); + } + } + else + { + const uword n_rows = P.get_n_rows(); + const uword n_cols = P.get_n_cols(); + + if(n_rows == 1) + { + for(uword col=0; col<n_cols; ++col) + { + const std::complex<T>& X = P.at(0,col); + + const T a = X.real(); + const T b = X.imag(); + + acc += std::sqrt( (a*a) + (b*b) ); + } + } + else + { + for(uword col=0; col<n_cols; ++col) + for(uword row=0; row<n_rows; ++row) + { + const std::complex<T>& X = P.at(row,col); + + const T a = X.real(); + const T b = X.imag(); + + acc += std::sqrt( (a*a) + (b*b) ); + } + } + } + + if( (acc != T(0)) && arma_isfinite(acc) ) + { + return acc; + } + else + { + arma_extra_debug_print("arma_vec_norm_1(): detected possible underflow or overflow"); + + const quasi_unwrap<typename Proxy<T1>::stored_type> R(P.Q); + + const uword N = R.M.n_elem; + const eT* R_mem = R.M.memptr(); + + T max_val = priv::most_neg<T>(); + + for(uword i=0; i<N; ++i) + { + const std::complex<T>& X = R_mem[i]; + + const T a = std::abs(X.real()); + const T b = std::abs(X.imag()); + + if(a > max_val) { max_val = a; } + if(b > max_val) { max_val = b; } + } + + if(max_val == T(0)) { return T(0); } + + T alt_acc = T(0); + + for(uword i=0; i<N; ++i) + { + const std::complex<T>& X = R_mem[i]; + + const T a = X.real() / max_val; + const T b = X.imag() / max_val; + + alt_acc += std::sqrt( (a*a) + (b*b) ); + } + + return ( alt_acc * max_val ); + } + } + + + +template<typename T1> +arma_hot +inline +typename T1::pod_type arma_vec_norm_2 ( const Proxy<T1>& P, @@ -263,8 +385,12 @@ for(uword i=0; i<N; ++i) { - const T tmp = std::abs(A[i]); - acc += tmp*tmp; + const std::complex<T>& X = A[i]; + + const T a = X.real(); + const T b = X.imag(); + + acc += (a*a) + (b*b); } } else @@ -276,8 +402,12 @@ { for(uword col=0; col<n_cols; ++col) { - const T tmp = std::abs(P.at(0,col)); - acc += tmp*tmp; + const std::complex<T>& X = P.at(0,col); + + const T a = X.real(); + const T b = X.imag(); + + acc += (a*a) + (b*b); } } else @@ -285,8 +415,12 @@ for(uword col=0; col<n_cols; ++col) for(uword row=0; row<n_rows; ++row) { - const T tmp = std::abs(P.at(row,col)); - acc += tmp*tmp; + const std::complex<T>& X = P.at(row,col); + + const T a = X.real(); + const T b = X.imag(); + + acc += (a*a) + (b*b); } } } @@ -596,7 +730,7 @@ const bool is_vec = (P.get_n_rows() == 1) || (P.get_n_cols() == 1); - if(is_vec == true) + if(is_vec) { switch(k) { @@ -632,6 +766,8 @@ return T(0); } } + + return T(0); // prevent erroneous compiler warnings } @@ -662,7 +798,7 @@ const char sig = (method != NULL) ? method[0] : char(0); const bool is_vec = (P.get_n_rows() == 1) || (P.get_n_cols() == 1); - if(is_vec == true) + if(is_vec) { if( (sig == 'i') || (sig == 'I') || (sig == '+') ) // max norm { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-4.450.0/include/armadillo_bits/gmm_diag_meat.hpp new/armadillo-4.450.3/include/armadillo_bits/gmm_diag_meat.hpp --- old/armadillo-4.450.0/include/armadillo_bits/gmm_diag_meat.hpp 2014-09-01 07:44:08.000000000 +0200 +++ new/armadillo-4.450.3/include/armadillo_bits/gmm_diag_meat.hpp 2014-09-30 11:10:22.000000000 +0200 @@ -289,26 +289,26 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - Col<eT> out( (n_gaus > 0) ? n_dims : uword(0) ); + Col<eT> out( (N_gaus > 0) ? N_dims : uword(0) ); - if(n_gaus > 0) + if(N_gaus > 0) { const double val = randu<double>(); double csum = double(0); uword gaus_id = 0; - for(uword j=0; j < n_gaus; ++j) + for(uword j=0; j < N_gaus; ++j) { csum += hefts[j]; if(val <= csum) { gaus_id = j; break; } } - out = randn< Col<eT> >(n_dims); + out = randn< Col<eT> >(N_dims); out %= sqrt(dcovs.col(gaus_id)); out += means.col(gaus_id); } @@ -321,27 +321,27 @@ template<typename eT> inline Mat<eT> -gmm_diag<eT>::generate(const uword N) const +gmm_diag<eT>::generate(const uword N_vec) const { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - Mat<eT> out( ( (n_gaus > 0) ? n_dims : uword(0) ), N ); + Mat<eT> out( ( (N_gaus > 0) ? N_dims : uword(0) ), N_vec ); - if(n_gaus > 0) + if(N_gaus > 0) { const eT* hefts_mem = hefts.memptr(); - for(uword i=0; i < N; ++i) + for(uword i=0; i < N_vec; ++i) { const double val = randu<double>(); double csum = double(0); uword gaus_id = 0; - for(uword j=0; j < n_gaus; ++j) + for(uword j=0; j < N_gaus; ++j) { csum += hefts_mem[j]; @@ -350,7 +350,7 @@ subview_col<eT> out_col = out.col(i); - out_col = randn< Col<eT> >(n_dims); + out_col = randn< Col<eT> >(N_dims); out_col %= sqrt(dcovs.col(gaus_id)); out_col += means.col(gaus_id); } @@ -628,7 +628,7 @@ gmm_diag<eT>::learn ( const Base<eT,T1>& data, - const uword n_gaus, + const uword N_gaus, const gmm_dist_mode& dist_mode, const gmm_seed_mode& seed_mode, const uword km_iter, @@ -658,7 +658,7 @@ if(X.is_empty() ) { arma_warn(true, "gmm_diag::learn(): given matrix is empty" ); reset(); return false; } if(X.is_finite() == false) { arma_warn(true, "gmm_diag::learn(): given matrix has non-finite values"); reset(); return false; } - if(n_gaus == 0) { reset(); return true; } + if(N_gaus == 0) { reset(); return true; } if(dist_mode == maha_dist) { @@ -689,9 +689,9 @@ } else { - if(X.n_cols < n_gaus) { arma_warn(true, "gmm_diag::learn(): number of vectors is less than number of gaussians"); reset(); return false; } + if(X.n_cols < N_gaus) { arma_warn(true, "gmm_diag::learn(): number of vectors is less than number of gaussians"); reset(); return false; } - reset(X.n_rows, n_gaus); + reset(X.n_rows, N_gaus); if(print_mode) { get_stream_err2() << "gmm_diag::learn(): generating initial means\n"; } @@ -806,14 +806,14 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - const eT tmp = (eT(n_dims)/eT(2)) * std::log(eT(2) * Datum<eT>::pi); + const eT tmp = (eT(N_dims)/eT(2)) * std::log(eT(2) * Datum<eT>::pi); - log_det_etc.set_size(n_gaus); + log_det_etc.set_size(N_gaus); - for(uword i=0; i<n_gaus; ++i) + for(uword i=0; i<N_gaus; ++i) { const eT logdet = accu( log(dcovs.col(i)) ); @@ -835,13 +835,13 @@ const eT* log_hefts_mem = log_hefts.mem; - const uword n_gaus = means.n_cols; + const uword N_gaus = means.n_cols; - if(n_gaus > 0) + if(N_gaus > 0) { eT log_sum = internal_scalar_log_p(x, 0) + log_hefts_mem[0]; - for(uword g=1; g < n_gaus; ++g) + for(uword g=1; g < N_gaus; ++g) { const eT tmp = internal_scalar_log_p(x, g) + log_hefts_mem[g]; @@ -869,14 +869,14 @@ const eT* mean = means.colptr(g); const eT* dcov = dcovs.colptr(g); - const uword n_dims = means.n_rows; + const uword N_dims = means.n_rows; eT val_i = eT(0); eT val_j = eT(0); uword i,j; - for(i=0, j=1; j<n_dims; i+=2, j+=2) + for(i=0, j=1; j<N_dims; i+=2, j+=2) { eT tmp_i = x[i]; eT tmp_j = x[j]; @@ -888,7 +888,7 @@ val_j += (tmp_j*tmp_j) / dcov[j]; } - if(i < n_dims) + if(i < N_dims) { const eT tmp = x[i] - mean[i]; @@ -1010,11 +1010,11 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - arma_debug_check( (X.n_rows != n_dims), "gmm_diag::assign(): incompatible dimensions" ); - arma_debug_check( (n_gaus == 0), "gmm_diag::assign(): model has no means" ); + arma_debug_check( (X.n_rows != N_dims), "gmm_diag::assign(): incompatible dimensions" ); + arma_debug_check( (N_gaus == 0), "gmm_diag::assign(): model has no means" ); const eT* X_mem = X.colptr(0); @@ -1023,9 +1023,9 @@ eT best_dist = Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { - const eT tmp_dist = distance<eT,1>::eval(n_dims, X_mem, means.colptr(g), X_mem); + const eT tmp_dist = distance<eT,1>::eval(N_dims, X_mem, means.colptr(g), X_mem); if(tmp_dist <= best_dist) { @@ -1044,7 +1044,7 @@ eT best_p = -Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { const eT tmp_p = internal_scalar_log_p(X_mem, g) + log_hefts_mem[g]; @@ -1075,12 +1075,12 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - arma_debug_check( (X.n_rows != n_dims), "gmm_diag::assign(): incompatible dimensions" ); + arma_debug_check( (X.n_rows != N_dims), "gmm_diag::assign(): incompatible dimensions" ); - const uword X_n_cols = (n_gaus > 0) ? X.n_cols : 0; + const uword X_n_cols = (N_gaus > 0) ? X.n_cols : 0; out.set_size(1,X_n_cols); @@ -1095,9 +1095,9 @@ eT best_dist = Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g<n_gaus; ++g) + for(uword g=0; g<N_gaus; ++g) { - const eT tmp_dist = distance<eT,1>::eval(n_dims, X_colptr, means.colptr(g), X_colptr); + const eT tmp_dist = distance<eT,1>::eval(N_dims, X_colptr, means.colptr(g), X_colptr); if(tmp_dist <= best_dist) { @@ -1121,7 +1121,7 @@ eT best_p = -Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g<n_gaus; ++g) + for(uword g=0; g<N_gaus; ++g) { const eT tmp_p = internal_scalar_log_p(X_colptr, g) + log_hefts_mem[g]; @@ -1151,14 +1151,14 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; const uword X_n_cols = X.n_cols; - hist.zeros(n_gaus); + hist.zeros(N_gaus); - if(n_gaus == 0) { return; } + if(N_gaus == 0) { return; } uword* hist_mem = hist.memptr(); @@ -1171,9 +1171,9 @@ eT best_dist = Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { - const eT tmp_dist = distance<eT,1>::eval(n_dims, X_colptr, means.colptr(g), X_colptr); + const eT tmp_dist = distance<eT,1>::eval(N_dims, X_colptr, means.colptr(g), X_colptr); if(tmp_dist <= best_dist) { @@ -1197,7 +1197,7 @@ eT best_p = -Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { const eT tmp_p = internal_scalar_log_p(X_colptr, g) + log_hefts_mem[g]; @@ -1221,15 +1221,15 @@ void gmm_diag<eT>::generate_initial_means(const Mat<eT>& X, const gmm_seed_mode& seed_mode) { - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; if( (seed_mode == static_subset) || (seed_mode == random_subset) ) { uvec initial_indices; - if(seed_mode == static_subset) { initial_indices = linspace<uvec>(0, X.n_cols-1, n_gaus); } - else if(seed_mode == random_subset) { initial_indices = sort_index(randu<vec>(X.n_cols)).rows(0,n_gaus-1); } + if(seed_mode == static_subset) { initial_indices = linspace<uvec>(0, X.n_cols-1, N_gaus); } + else if(seed_mode == random_subset) { initial_indices = sort_index(randu<vec>(X.n_cols)).rows(0,N_gaus-1); } // not using randi() here as on some primitive systems it produces vectors with non-unique values @@ -1251,7 +1251,7 @@ running_stat<double> rs; - for(uword g=1; g < n_gaus; ++g) + for(uword g=1; g < N_gaus; ++g) { eT max_dist = eT(0); uword best_i = uword(0); @@ -1267,7 +1267,7 @@ // find the average distance between sample i and the means so far for(uword h = 0; h < g; ++h) { - const eT dist = distance<eT,dist_id>::eval(n_dims, X_colptr, means.colptr(h), mah_aux_mem); + const eT dist = distance<eT,dist_id>::eval(N_dims, X_colptr, means.colptr(h), mah_aux_mem); // ignore sample already selected as a mean if(dist == eT(0)) { ignore_i = true; break; } @@ -1297,10 +1297,10 @@ void gmm_diag<eT>::generate_initial_dcovs_and_hefts(const Mat<eT>& X, const eT var_floor) { - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - field< running_stat_vec< Col<eT> > > rs(n_gaus); + field< running_stat_vec< Col<eT> > > rs(N_gaus); const eT* mah_aux_mem = mah_aux.memptr(); @@ -1311,9 +1311,9 @@ double min_dist = Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g<n_gaus; ++g) + for(uword g=0; g<N_gaus; ++g) { - const double dist = distance<eT,dist_id>::eval(n_dims, X_colptr, means.colptr(g), mah_aux_mem); + const double dist = distance<eT,dist_id>::eval(N_dims, X_colptr, means.colptr(g), mah_aux_mem); if(dist <= min_dist) { min_dist = dist; best_g = g; } } @@ -1321,7 +1321,7 @@ rs(best_g)(X.unsafe_col(i)); } - for(uword g=0; g<n_gaus; ++g) + for(uword g=0; g<N_gaus; ++g) { if( rs(g).count() >= eT(2) ) { @@ -1340,7 +1340,7 @@ - +//! multi-threaded implementation of k-means, inspired by MapReduce template<typename eT> template<uword dist_id> inline @@ -1349,9 +1349,6 @@ { arma_extra_debug_sigprint(); - // get_stream_err2() << "km_iterate()" << '\n'; - // get_stream_err2() << "dist_id: " << dist_id << '\n'; - if(verbose) { get_stream_err2().unsetf(ios::showbase); @@ -1363,20 +1360,19 @@ get_stream_err2().setf(ios::fixed); } - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; Mat<eT> old_means = means; Mat<eT> new_means = means; running_mean_scalar<double> rs_delta; - field< running_mean_vec<eT> > running_means(n_gaus); + field< running_mean_vec<eT> > running_means(N_gaus); const eT* mah_aux_mem = mah_aux.memptr(); - #if defined(_OPENMP) const arma_omp_state save_omp_state; @@ -1388,28 +1384,28 @@ field< field< running_mean_vec<eT> > > t_running_means(n_threads); - for(uword t=0; t < n_threads; ++t) { t_running_means[t].set_size(n_gaus); } + for(uword t=0; t < n_threads; ++t) { t_running_means[t].set_size(N_gaus); } field< uvec > t_boundary(n_threads); const uword chunk_size = X.n_cols / n_threads; - uword count = 0; + uword vec_count = 0; for(uword t=0; t<n_threads; t++) { t_boundary[t].set_size(2); - t_boundary[t][0] = count; + t_boundary[t][0] = vec_count; - count += chunk_size; + vec_count += chunk_size; - t_boundary[t][1] = count-1; + t_boundary[t][1] = vec_count-1; } t_boundary[n_threads-1][1] = X.n_cols - 1; - vec tmp_mean(n_dims); + vec tmp_mean(N_dims); if(verbose) { @@ -1425,9 +1421,12 @@ { for(uword t=0; t < n_threads; ++t) { - for(uword g=0; g < n_gaus; ++g) { t_running_means[t][g].reset(); } + for(uword g=0; g < N_gaus; ++g) { t_running_means[t][g].reset(); } } + + // km_update_stats() is the "map" operation, which produces partial means + #pragma omp parallel for for(uword t=0; t < n_threads; ++t) { @@ -1438,9 +1437,11 @@ km_update_stats<dist_id>(X, boundary[0], boundary[1], old_means, current_running_means); } - // the "reduce" operation, which combines the results produced by seperate threads; + + // the "reduce" operation, which combines the partial means produced by the separate threads; // takes into account the counts for each mean - for(uword g=0; g < n_gaus; ++g) + + for(uword g=0; g < N_gaus; ++g) { uword total_count = 0; @@ -1474,7 +1475,7 @@ } #else { - for(uword g=0; g < n_gaus; ++g) { running_means[g].reset(); } + for(uword g=0; g < N_gaus; ++g) { running_means[g].reset(); } km_update_stats<dist_id>(X, 0, X.n_cols-1, old_means, running_means); } @@ -1482,7 +1483,7 @@ uword n_dead_means = 0; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { if(running_means[g].count() > 0) { @@ -1504,7 +1505,7 @@ uword populous_g = 0; uword populous_count = running_means(0).count(); - for(uword g=1; g < n_gaus; ++g) + for(uword g=1; g < N_gaus; ++g) { const uword count = running_means(g).count(); @@ -1525,11 +1526,11 @@ { uword dead_g = 0; - for(uword live_g = 0; live_g < n_gaus; ++live_g) + for(uword live_g = 0; live_g < N_gaus; ++live_g) { if(running_means(live_g).count() >= 2) { - for(; dead_g < n_gaus; ++dead_g) + for(; dead_g < N_gaus; ++dead_g) { if(running_means(dead_g).count() == 0) { break; } } @@ -1544,9 +1545,9 @@ rs_delta.reset(); - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { - rs_delta( distance<eT,dist_id>::eval(n_dims, old_means.colptr(g), new_means.colptr(g), mah_aux_mem) ); + rs_delta( distance<eT,dist_id>::eval(N_dims, old_means.colptr(g), new_means.colptr(g), mah_aux_mem) ); } if(verbose) @@ -1585,8 +1586,8 @@ // get_stream_err2() << "km_update_stats(): start_index: " << start_index << '\n'; // get_stream_err2() << "km_update_stats(): end_index: " << end_index << '\n'; - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; const eT* mah_aux_mem = mah_aux.memptr(); @@ -1597,9 +1598,9 @@ double best_dist = Datum<eT>::inf; uword best_g = 0; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { - const double dist = distance<eT,dist_id>::eval(n_dims, X_colptr, old_means.colptr(g), mah_aux_mem); + const double dist = distance<eT,dist_id>::eval(N_dims, X_colptr, old_means.colptr(g), mah_aux_mem); // get_stream_err2() << "g: " << g << " dist: " << dist << '\n'; // old_means.col(g).print("old_means.col(g):"); @@ -1617,6 +1618,7 @@ +//! multi-threaded implementation of Expectation-Maximisation, inspired by MapReduce template<typename eT> inline bool @@ -1624,8 +1626,8 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; if(verbose) { @@ -1668,11 +1670,11 @@ { t_boundary[t].set_size(2); - t_acc_means[t].set_size(n_dims, n_gaus); - t_acc_dcovs[t].set_size(n_dims, n_gaus); + t_acc_means[t].set_size(N_dims, N_gaus); + t_acc_dcovs[t].set_size(N_dims, N_gaus); - t_acc_norm_lhoods[t].set_size(n_gaus); - t_gaus_log_lhoods[t].set_size(n_gaus); + t_acc_norm_lhoods[t].set_size(N_gaus); + t_gaus_log_lhoods[t].set_size(N_gaus); } const uword chunk_size = X.n_cols / n_threads; @@ -1764,6 +1766,9 @@ const uword n_threads = t_boundary.n_elem; + + // em_generate_acc() is the "map" operation, which produces partial accumulators for means, diagonal covariances and hefts + #if defined(_OPENMP) { #pragma omp parallel for @@ -1785,14 +1790,17 @@ } #endif - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; Mat<eT>& final_acc_means = t_acc_means[0]; Mat<eT>& final_acc_dcovs = t_acc_dcovs[0]; Col<eT>& final_acc_norm_lhoods = t_acc_norm_lhoods[0]; + + // the "reduce" operation, which combines the partial accumulators produced by the separate threads + for(uword t=1; t<n_threads; t++) { final_acc_means += t_acc_means[t]; @@ -1804,7 +1812,7 @@ eT* hefts_mem = access::rw(hefts).memptr(); - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { eT* mean_mem = access::rw(means).colptr(g); eT* dcov_mem = access::rw(dcovs).colptr(g); @@ -1816,7 +1824,7 @@ hefts_mem[g] = acc_norm_lhood / eT(X.n_cols); - for(uword d=0; d < n_dims; ++d) + for(uword d=0; d < N_dims; ++d) { const eT tmp = acc_mean_mem[d] / acc_norm_lhood; @@ -1854,7 +1862,7 @@ gaus_log_lhoods.zeros(); const uword n_dim = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_gaus = means.n_cols; const eT* log_hefts_mem = log_hefts.memptr(); eT* gaus_log_lhoods_mem = gaus_log_lhoods.memptr(); @@ -1866,21 +1874,21 @@ { const eT* x = X.colptr(i); - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { gaus_log_lhoods_mem[g] = internal_scalar_log_p(x, g) + log_hefts_mem[g]; } eT log_lhood_sum = gaus_log_lhoods_mem[0]; - for(uword g=1; g < n_gaus; ++g) + for(uword g=1; g < N_gaus; ++g) { log_lhood_sum = log_add_exp(log_lhood_sum, gaus_log_lhoods_mem[g]); } progress_log_lhood += log_lhood_sum; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { const eT norm_lhood = std::exp(gaus_log_lhoods_mem[g] - log_lhood_sum); @@ -1912,14 +1920,14 @@ { arma_extra_debug_sigprint(); - const uword n_dims = means.n_rows; - const uword n_gaus = means.n_cols; + const uword N_dims = means.n_rows; + const uword N_gaus = means.n_cols; - for(uword g=0; g < n_gaus; ++g) + for(uword g=0; g < N_gaus; ++g) { eT* dcov_mem = access::rw(dcovs).colptr(g); - for(uword d=0; d < n_dims; ++d) + for(uword d=0; d < N_dims; ++d) { if(dcov_mem[d] < var_floor) { dcov_mem[d] = var_floor; } } -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org