Hello community, here is the log from the commit of package armadillo for openSUSE:Factory checked in at 2017-12-19 10:58:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/armadillo (Old) and /work/SRC/openSUSE:Factory/.armadillo.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "armadillo" Tue Dec 19 10:58:42 2017 rev:117 rq:558067 version:8.300.2 Changes: -------- --- /work/SRC/openSUSE:Factory/armadillo/armadillo.changes 2017-11-23 09:44:20.996654663 +0100 +++ /work/SRC/openSUSE:Factory/.armadillo.new/armadillo.changes 2017-12-19 10:58:43.972639589 +0100 @@ -1,0 +2,6 @@ +Mon Dec 18 06:14:55 UTC 2017 - badshah...@gmail.com + +- Update to version 8.300.2: + + Misc bug fixes. + +------------------------------------------------------------------- Old: ---- armadillo-8.300.0.tar.xz New: ---- armadillo-8.300.2.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ armadillo.spec ++++++ --- /var/tmp/diff_new_pack.GzZcTB/_old 2017-12-19 10:58:44.680605412 +0100 +++ /var/tmp/diff_new_pack.GzZcTB/_new 2017-12-19 10:58:44.680605412 +0100 @@ -18,7 +18,7 @@ %define soname libarmadillo8 Name: armadillo -Version: 8.300.0 +Version: 8.300.2 Release: 0 Summary: C++ matrix library with interfaces to LAPACK and ATLAS License: Apache-2.0 ++++++ armadillo-8.300.0.tar.xz -> armadillo-8.300.2.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/README.txt new/armadillo-8.300.2/README.txt --- old/armadillo-8.300.0/README.txt 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/README.txt 2016-06-16 18:17:22.000000000 +0200 @@ -25,7 +25,7 @@ 9: Support for OpenBLAS and Intel MKL 10: Support for ATLAS -11: Support for C++11/C++14 Features +11: Support for C++11 / C++14 Features 12: Support for OpenMP 13: API Documentation @@ -375,7 +375,7 @@ Armadillo can use OpenMP to automatically speed up computationally expensive element-wise functions such as exp(), log(), cos(), etc. -This requires a C++11/C++14 compiler with OpenMP 3.0+ support. +This requires a C++11/C++14 compiler with OpenMP 3.1+ support. When using gcc or clang, use the following options to enable both C++11 and OpenMP: -std=c++11 -fopenmp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/docs.html new/armadillo-8.300.2/docs.html --- old/armadillo-8.300.0/docs.html 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/docs.html 2016-06-16 18:17:22.000000000 +0200 @@ -16216,7 +16216,7 @@ <td style="vertical-align: top;"> Use OpenMP for parallelisation of computationally expensive element-wise operations (such as <a href="#misc_fns">exp()</a>, <a href="#misc_fns">log()</a>, <a href="#trig_fns">cos()</a>, etc). -Automatically enabled when using a C++11/C++14 compiler which has OpenMP 3.0+ active (eg. the <code>-fopenmp</code> option for gcc and clang). +Automatically enabled when using a C++11/C++14 compiler which has OpenMP 3.1+ active (eg. the <code>-fopenmp</code> option for gcc and clang). <b>Caveat:</b> when using gcc, use of <code>-march=native</code> in conjunction with <code>-fopenmp</code> may lead to speed regressions on recent processors. </td> </tr> @@ -16820,7 +16820,7 @@ <li> computationally expensive element-wise functions (such as <a href="#misc_fns">exp()</a>, <a href="#misc_fns">log()</a>, <a href="#trig_fns">cos()</a>, etc) can now be automatically sped up via <a href="https://en.wikipedia.org/wiki/OpenMP">OpenMP</a>; -this requires a C++11/C++14 compiler with OpenMP 3.0+ support +this requires a C++11/C++14 compiler with OpenMP 3.1+ support <ul> <li>for GCC and clang compilers use the following options to enable both C++11 and OpenMP: <code>-std=c++11 -fopenmp</code></li> <li><b>Caveat:</b> when using GCC, use of <code>-march=native</code> in conjunction with <code>-fopenmp</code> may lead to speed regressions on recent processors</li> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo new/armadillo-8.300.2/include/armadillo --- old/armadillo-8.300.0/include/armadillo 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo 2016-06-16 18:17:22.000000000 +0200 @@ -59,6 +59,8 @@ #include <random> #include <functional> #include <chrono> + #include <mutex> + #include <atomic> #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/MapMat_bones.hpp new/armadillo-8.300.2/include/armadillo_bits/MapMat_bones.hpp --- old/armadillo-8.300.0/include/armadillo_bits/MapMat_bones.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/MapMat_bones.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -80,9 +80,9 @@ inline void speye(const uword in_n_rows, const uword in_n_cols); inline void speye(const SizeMat& s); - arma_inline MapMat_elem<eT> elem(const uword index, uword& sync_state, uword& n_nonzero); - arma_inline MapMat_elem<eT> elem(const uword in_row, const uword in_col, uword& sync_state, uword& n_nonzero); - arma_inline MapMat_svel<eT> svel(const uword in_row, const uword in_col, uword& sync_state, uword& n_nonzero, uword& sv_n_nonzero); + arma_inline MapMat_elem<eT> elem(const uword index, state_type& sync_state, uword& n_nonzero); + arma_inline MapMat_elem<eT> elem(const uword in_row, const uword in_col, state_type& sync_state, uword& n_nonzero); + arma_inline MapMat_svel<eT> svel(const uword in_row, const uword in_col, state_type& sync_state, uword& n_nonzero, uword& sv_n_nonzero); arma_inline arma_warn_unused MapMat_val<eT> operator[](const uword index); arma_inline arma_warn_unused eT operator[](const uword index) const; @@ -169,11 +169,11 @@ arma_aligned MapMat<eT>& parent; - arma_aligned const uword index; - arma_aligned uword& sync_state; - arma_aligned uword& n_nonzero; + arma_aligned const uword index; + arma_aligned state_type& sync_state; + arma_aligned uword& n_nonzero; - inline MapMat_elem(MapMat<eT>& in_parent, const uword in_index, uword& in_sync_state, uword& in_n_nonzero); + inline MapMat_elem(MapMat<eT>& in_parent, const uword in_index, state_type& in_sync_state, uword& in_n_nonzero); friend class MapMat<eT>; @@ -206,12 +206,12 @@ arma_aligned MapMat<eT>& parent; - arma_aligned const uword index; - arma_aligned uword& sync_state; - arma_aligned uword& n_nonzero; - arma_aligned uword& sv_n_nonzero; + arma_aligned const uword index; + arma_aligned state_type& sync_state; + arma_aligned uword& n_nonzero; + arma_aligned uword& sv_n_nonzero; - inline MapMat_svel(MapMat<eT>& in_parent, const uword in_index, uword& in_sync_state, uword& in_n_nonzero, uword& in_sv_n_nonzero); + inline MapMat_svel(MapMat<eT>& in_parent, const uword in_index, state_type& in_sync_state, uword& in_n_nonzero, uword& in_sv_n_nonzero); arma_inline void update_n_nonzeros(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/MapMat_meat.hpp new/armadillo-8.300.2/include/armadillo_bits/MapMat_meat.hpp --- old/armadillo-8.300.0/include/armadillo_bits/MapMat_meat.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/MapMat_meat.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -415,7 +415,7 @@ template<typename eT> arma_inline MapMat_elem<eT> -MapMat<eT>::elem(const uword index, uword& sync_state, uword& n_nonzero) +MapMat<eT>::elem(const uword index, state_type& sync_state, uword& n_nonzero) { return MapMat_elem<eT>(*this, index, sync_state, n_nonzero); } @@ -425,7 +425,7 @@ template<typename eT> arma_inline MapMat_elem<eT> -MapMat<eT>::elem(const uword in_row, const uword in_col, uword& sync_state, uword& n_nonzero) +MapMat<eT>::elem(const uword in_row, const uword in_col, state_type& sync_state, uword& n_nonzero) { const uword index = (n_rows * in_col) + in_row; @@ -437,7 +437,7 @@ template<typename eT> arma_inline MapMat_svel<eT> -MapMat<eT>::svel(const uword in_row, const uword in_col, uword& sync_state, uword& n_nonzero, uword& sv_n_nonzero) +MapMat<eT>::svel(const uword in_row, const uword in_col, state_type& sync_state, uword& n_nonzero, uword& sv_n_nonzero) { const uword index = (n_rows * in_col) + in_row; @@ -1120,7 +1120,7 @@ template<typename eT> arma_inline -MapMat_elem<eT>::MapMat_elem(MapMat<eT>& in_parent, const uword in_index, uword& in_sync_state, uword& in_n_nonzero) +MapMat_elem<eT>::MapMat_elem(MapMat<eT>& in_parent, const uword in_index, state_type& in_sync_state, uword& in_n_nonzero) : parent (in_parent ) , index (in_index ) , sync_state(in_sync_state) @@ -1415,7 +1415,7 @@ template<typename eT> arma_inline -MapMat_svel<eT>::MapMat_svel(MapMat<eT>& in_parent, const uword in_index, uword& in_sync_state, uword& in_n_nonzero, uword& in_sv_n_nonzero) +MapMat_svel<eT>::MapMat_svel(MapMat<eT>& in_parent, const uword in_index, state_type& in_sync_state, uword& in_n_nonzero, uword& in_sv_n_nonzero) : parent (in_parent ) , index (in_index ) , sync_state (in_sync_state ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/SpMat_bones.hpp new/armadillo-8.300.2/include/armadillo_bits/SpMat_bones.hpp --- old/armadillo-8.300.0/include/armadillo_bits/SpMat_bones.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/SpMat_bones.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -601,16 +601,20 @@ // cache related arma_aligned mutable MapMat<eT> cache; - arma_aligned mutable uword sync_state; + arma_aligned mutable state_type sync_state; // 0: cache needs to be updated from CSC // 1: CSC needs to be updated from cache // 2: no update required + #if !defined(_OPENMP) && defined(ARMA_USE_CXX11) + arma_aligned mutable std::mutex cache_mutex; + #endif + arma_inline void invalidate_cache() const; arma_inline void invalidate_csc() const; - arma_inline void sync_cache() const; - arma_inline void sync_csc() const; + inline void sync_cache() const; + inline void sync_csc() const; friend class SpValProxy< SpMat<eT> >; // allow SpValProxy to call insert_element() and delete_element() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/SpMat_meat.hpp new/armadillo-8.300.2/include/armadillo_bits/SpMat_meat.hpp --- old/armadillo-8.300.0/include/armadillo_bits/SpMat_meat.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/SpMat_meat.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -5688,7 +5688,6 @@ arma_extra_debug_sigprint(); cache.reset(); - sync_state = 0; } @@ -5707,18 +5706,44 @@ template<typename eT> -arma_inline +inline void SpMat<eT>::sync_cache() const { arma_extra_debug_sigprint(); - #if defined(_OPENMP) - #pragma omp critical + // using approach adapted from http://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/ + // + // OpenMP mode: + // sync_state uses atomic read/write, which has an implied flush; + // flush is also implicitly executed at the entrance and the exit of critical section; + // data races are prevented by the 'critical' directive + // + // C++11 mode: + // underlying type for sync_state is std::atomic<int>; + // reading and writing to sync_state uses std::memory_order_seq_cst which has an implied fence; + // data races are prevented via the mutex + + #if defined(ARMA_USE_OPENMP) if(sync_state == 0) { - cache = (*this); - sync_state = 2; + #pragma omp critical + if(sync_state == 0) + { + cache = (*this); + sync_state = 2; + } + } + #elif defined(ARMA_USE_CXX11) + if(sync_state == 0) + { + cache_mutex.lock(); + if(sync_state == 0) + { + cache = (*this); + sync_state = 2; + } + cache_mutex.unlock(); } #else if(sync_state == 0) @@ -5746,17 +5771,38 @@ // sync_state is only set to 1 by non-const element access operators, // so the shenanigans with const_cast are to satisfy the compiler - #if defined(_OPENMP) - #pragma omp critical + // see also the note in sync_cache() above + + #if defined(ARMA_USE_OPENMP) if(sync_state == 1) { - SpMat<eT> tmp(cache); - - SpMat<eT>& x = const_cast< SpMat<eT>& >(*this); - - x.steal_mem_simple(tmp); - - sync_state = 2; + #pragma omp critical + if(sync_state == 1) + { + SpMat<eT> tmp(cache); + + SpMat<eT>& x = const_cast< SpMat<eT>& >(*this); + + x.steal_mem_simple(tmp); + + sync_state = 2; + } + } + #elif defined(ARMA_USE_CXX11) + if(sync_state == 1) + { + cache_mutex.lock(); + if(sync_state == 1) + { + SpMat<eT> tmp(cache); + + SpMat<eT>& x = const_cast< SpMat<eT>& >(*this); + + x.steal_mem_simple(tmp); + + sync_state = 2; + } + cache_mutex.unlock(); } #else if(sync_state == 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/arma_forward.hpp new/armadillo-8.300.2/include/armadillo_bits/arma_forward.hpp --- old/armadillo-8.300.0/include/armadillo_bits/arma_forward.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/arma_forward.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -227,6 +227,51 @@ class spglue_times; class spglue_times2; +struct state_type + { + #if defined(ARMA_USE_OPENMP) + int state; + #elif defined(ARMA_USE_CXX11) + std::atomic<int> state; + #else + int state; + #endif + + // openmp: "omp atomic" does an implicit flush on the affected variable + // C++11: std::atomic<>::load() and std::atomic<>::store() use std::memory_order_seq_cst by default, which has an implied fence + + arma_inline + operator int () const + { + int out; + + #if defined(ARMA_USE_OPENMP) + #pragma omp atomic read + out = state; + #elif defined(ARMA_USE_CXX11) + out = state.load(); + #else + out = state; + #endif + + return out; + } + + arma_inline + void + operator= (const int in_state) + { + #if defined(ARMA_USE_OPENMP) + #pragma omp atomic write + state = in_state; + #elif defined(ARMA_USE_CXX11) + state.store(in_state); + #else + state = in_state; + #endif + } + }; + template< typename T1, typename spop_type> class SpOp; template<typename out_eT, typename T1, typename spop_type> class mtSpOp; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/arma_version.hpp new/armadillo-8.300.2/include/armadillo_bits/arma_version.hpp --- old/armadillo-8.300.0/include/armadillo_bits/arma_version.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/arma_version.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -21,7 +21,7 @@ #define ARMA_VERSION_MAJOR 8 #define ARMA_VERSION_MINOR 300 -#define ARMA_VERSION_PATCH 0 +#define ARMA_VERSION_PATCH 2 #define ARMA_VERSION_NAME "Tropical Shenanigans" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/compiler_extra.hpp new/armadillo-8.300.2/include/armadillo_bits/compiler_extra.hpp --- old/armadillo-8.300.0/include/armadillo_bits/compiler_extra.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/compiler_extra.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -30,7 +30,7 @@ #endif -#if (defined(_OPENMP) && (_OPENMP >= 200805)) +#if (defined(_OPENMP) && (_OPENMP >= 201107)) #undef ARMA_USE_OPENMP #define ARMA_USE_OPENMP #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/compiler_setup.hpp new/armadillo-8.300.2/include/armadillo_bits/compiler_setup.hpp --- old/armadillo-8.300.0/include/armadillo_bits/compiler_setup.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/compiler_setup.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -452,16 +452,17 @@ #endif -#if ( defined(ARMA_USE_OPENMP) && (!defined(_OPENMP) || (defined(_OPENMP) && (_OPENMP < 200805))) ) +#if ( defined(ARMA_USE_OPENMP) && (!defined(_OPENMP) || (defined(_OPENMP) && (_OPENMP < 201107))) ) // we require OpenMP 3.0 to enable parallelisation of for loops with unsigned integers; - // earlier versions of OpenMP can only handle signed integers + // earlier versions of OpenMP can only handle signed integers; + // we require OpenMP 3.1 for atomic read and atomic write #undef ARMA_USE_OPENMP #undef ARMA_PRINT_OPENMP_WARNING #define ARMA_PRINT_OPENMP_WARNING #endif -#if ( (defined(_OPENMP) && (_OPENMP < 200805)) && !defined(ARMA_DONT_USE_OPENMP) ) +#if ( (defined(_OPENMP) && (_OPENMP < 201107)) && !defined(ARMA_DONT_USE_OPENMP) ) // if the compiler has an ancient version of OpenMP and use of OpenMP hasn't been explicitly disabled, // print a warning to ensure there is no confusion about OpenMP support #undef ARMA_USE_OPENMP @@ -471,7 +472,7 @@ #if defined(ARMA_PRINT_OPENMP_WARNING) && !defined(ARMA_DONT_PRINT_OPENMP_WARNING) - #pragma message ("WARNING: use of OpenMP disabled; compiler support for OpenMP 3.0+ not detected") + #pragma message ("WARNING: use of OpenMP disabled; compiler support for OpenMP 3.1+ not detected") #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/config.hpp new/armadillo-8.300.2/include/armadillo_bits/config.hpp --- old/armadillo-8.300.0/include/armadillo_bits/config.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/config.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -95,7 +95,7 @@ #if !defined(ARMA_USE_OPENMP) // #define ARMA_USE_OPENMP //// Uncomment the above line to forcefully enable use of OpenMP for parallelisation. -//// Note that ARMA_USE_OPENMP is automatically enabled when a compiler supporting OpenMP 3.0 is detected. +//// Note that ARMA_USE_OPENMP is automatically enabled when a compiler supporting OpenMP 3.1 is detected. #endif #if !defined(ARMA_64BIT_WORD) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/config.hpp.cmake new/armadillo-8.300.2/include/armadillo_bits/config.hpp.cmake --- old/armadillo-8.300.0/include/armadillo_bits/config.hpp.cmake 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/config.hpp.cmake 2016-06-16 18:17:22.000000000 +0200 @@ -95,7 +95,7 @@ #if !defined(ARMA_USE_OPENMP) // #define ARMA_USE_OPENMP //// Uncomment the above line to forcefully enable use of OpenMP for parallelisation. -//// Note that ARMA_USE_OPENMP is automatically enabled when a compiler supporting OpenMP 3.0 is detected. +//// Note that ARMA_USE_OPENMP is automatically enabled when a compiler supporting OpenMP 3.1 is detected. #endif #if !defined(ARMA_64BIT_WORD) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/include/armadillo_bits/subview_field_meat.hpp new/armadillo-8.300.2/include/armadillo_bits/subview_field_meat.hpp --- old/armadillo-8.300.0/include/armadillo_bits/subview_field_meat.hpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/include/armadillo_bits/subview_field_meat.hpp 2016-06-16 18:17:22.000000000 +0200 @@ -156,28 +156,16 @@ oT& subview_field<oT>::operator[](const uword i) { - uword index; + const uword n_elem_slice = n_rows*n_cols; - if(n_slices == 1) - { - const uword in_col = i / n_rows; - const uword in_row = i % n_rows; - - index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - } - else - { - const uword n_elem_slice = n_rows*n_cols; - - const uword in_slice = i / n_elem_slice; - const uword offset = in_slice * n_elem_slice; - const uword j = i - offset; - - const uword in_col = j / n_rows; - const uword in_row = j % n_rows; - - index = (in_slice + aux_slice1)*(f.n_rows*f.n_cols) + (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - } + const uword in_slice = i / n_elem_slice; + const uword offset = in_slice * n_elem_slice; + const uword j = i - offset; + + const uword in_col = j / n_rows; + const uword in_row = j % n_rows; + + const uword index = (in_slice + aux_slice1)*(f.n_rows*f.n_cols) + (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; return *((const_cast< field<oT>& >(f)).mem[index]); } @@ -189,28 +177,16 @@ const oT& subview_field<oT>::operator[](const uword i) const { - uword index; + const uword n_elem_slice = n_rows*n_cols; + + const uword in_slice = i / n_elem_slice; + const uword offset = in_slice * n_elem_slice; + const uword j = i - offset; - if(n_slices == 1) - { - const uword in_col = i / n_rows; - const uword in_row = i % n_rows; - - index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - } - else - { - const uword n_elem_slice = n_rows*n_cols; - - const uword in_slice = i / n_elem_slice; - const uword offset = in_slice * n_elem_slice; - const uword j = i - offset; - - const uword in_col = j / n_rows; - const uword in_row = j % n_rows; - - index = (in_slice + aux_slice1)*(f.n_rows*f.n_cols) + (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - } + const uword in_col = j / n_rows; + const uword in_row = j % n_rows; + + const uword index = (in_slice + aux_slice1)*(f.n_rows*f.n_cols) + (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; return *(f.mem[index]); } @@ -246,11 +222,7 @@ oT& subview_field<oT>::operator()(const uword in_row, const uword in_col) { - arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols) || (0 >= n_slices)), "subview_field::operator(): index out of bounds" ); - - const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - - return *((const_cast< field<oT>& >(f)).mem[index]); + return operator()(in_row, in_col, 0); } @@ -260,11 +232,7 @@ const oT& subview_field<oT>::operator()(const uword in_row, const uword in_col) const { - arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols) || (0 >= n_slices)), "subview_field::operator(): index out of bounds" ); - - const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - - return *(f.mem[index]); + return operator()(in_row, in_col, 0); } @@ -302,9 +270,7 @@ oT& subview_field<oT>::at(const uword in_row, const uword in_col) { - const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - - return *((const_cast< field<oT>& >(f)).mem[index]); + return at(in_row, in_col, 0); } @@ -314,9 +280,7 @@ const oT& subview_field<oT>::at(const uword in_row, const uword in_col) const { - const uword index = (in_col + aux_col1)*f.n_rows + aux_row1 + in_row; - - return *(f.mem[index]); + return at(in_row, in_col, 0); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/tests/spcol.cpp new/armadillo-8.300.2/tests/spcol.cpp --- old/armadillo-8.300.0/tests/spcol.cpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/tests/spcol.cpp 2016-06-16 18:17:22.000000000 +0200 @@ -1,6 +1,4 @@ // Copyright 2011-2017 Ryan Curtin (http://www.ratml.org/) -// Copyright 2011-2012 Matthew Amidon -// Copyright 2011-2012 James Cline // Copyright 2017 National ICT Australia (NICTA) // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -105,7 +103,7 @@ REQUIRE( it == x.begin() ); - // Try removing an element we itreated to. + // Try removing an element we iterated to. it++; it++; *it = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/armadillo-8.300.0/tests/spmat.cpp new/armadillo-8.300.2/tests/spmat.cpp --- old/armadillo-8.300.0/tests/spmat.cpp 2016-06-16 18:17:20.000000000 +0200 +++ new/armadillo-8.300.2/tests/spmat.cpp 2016-06-16 18:17:22.000000000 +0200 @@ -1,6 +1,4 @@ // Copyright 2011-2017 Ryan Curtin (http://www.ratml.org/) -// Copyright 2011-2012 Matthew Amidon -// Copyright 2011-2012 James Cline // Copyright 2017 National ICT Australia (NICTA) // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -423,7 +421,7 @@ REQUIRE( it == x.begin_row() ); - // Try removing an element we itreated to. + // Try removing an element we iterated to. it++; it++; *it = 0;