diff --git a/ChangeLog b/ChangeLog index 1ed0acc0..47ee9a1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,25 @@ +2024-04-02 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): RcppArmadillo 0.12.8.2.0 + * inst/NEWS.Rd: Idem + * configure.ac: Idem + * configure: Idem + + * inst/include/armadillo_bits/: Armadillo 12.8.2 + 2024-03-05 Dirk Eddelbuettel * README.md: Correct a badge URL +2024-03-03 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): RcppArmadillo 0.12.8.1.0 + * inst/NEWS.Rd: Idem + * configure.ac: Idem + * configure: Idem + + * inst/include/armadillo_bits/: Armadillo 12.8.1 + 2024-02-19 Dirk Eddelbuettel * DESCRIPTION (Version, Date): Increment version counter diff --git a/DESCRIPTION b/DESCRIPTION index 88c2717c..c50d692e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: RcppArmadillo Type: Package Title: 'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library -Version: 0.12.8.1.0 -Date: 2024-03-02 +Version: 0.12.8.2.0 +Date: 2024-04-02 Author: Dirk Eddelbuettel, Romain Francois, Doug Bates, Binxiang Ni, and Conrad Sanderson Maintainer: Dirk Eddelbuettel Description: 'Armadillo' is a templated C++ linear algebra library (by Conrad diff --git a/README.md b/README.md index 91596029..a5622ecc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ [![CRAN use](https://jangorecki.gitlab.io/rdeps/RcppArmadillo/CRAN_usage.svg?sanitize=true)](https://cran.r-project.org/package=RcppArmadillo) [![CRAN indirect](https://jangorecki.gitlab.io/rdeps/RcppArmadillo/indirect_usage.svg?sanitize=true)](https://cran.r-project.org/package=RcppArmadillo) [![BioConductor use](https://jangorecki.gitlab.io/rdeps/RcppArmadillo/BioC_usage.svg?sanitize=true)](https://cran.r-project.org/package=RcppArmadillo) -[![StackOverflow](https://img.shields.io/badge/stackoverflow-rcpp-orange.svg)](https://stackoverflow.com/questions/tagged/rcpp) [![CSDA](https://img.shields.io/badge/CSDA-10.1016%2Fj.csda.2013.02.005-brightgreen)](https://doi.org/10.1016/j.csda.2013.02.005) ### Synopsis @@ -67,7 +66,7 @@ the switch saves about 15% of total compilation time. The package is mature yet under active development with releases to [CRAN][cran] about once every other month, and widely-used by other CRAN packages as can be seen from the [CRAN package page][cran -pkg]. As of February 2024, there are 1118 CRAN packages using RcppArmadillo. +pkg]. As of April 2024, there are 1135 CRAN packages using RcppArmadillo. ### Documentation diff --git a/configure b/configure index fdbc1a34..9e655154 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for RcppArmadillo 0.12.8.1.0. +# Generated by GNU Autoconf 2.71 for RcppArmadillo 0.12.8.2.0. # # Report bugs to . # @@ -610,8 +610,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='RcppArmadillo' PACKAGE_TARNAME='rcpparmadillo' -PACKAGE_VERSION='0.12.8.1.0' -PACKAGE_STRING='RcppArmadillo 0.12.8.1.0' +PACKAGE_VERSION='0.12.8.2.0' +PACKAGE_STRING='RcppArmadillo 0.12.8.2.0' PACKAGE_BUGREPORT='edd@debian.org' PACKAGE_URL='' @@ -1229,7 +1229,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures RcppArmadillo 0.12.8.1.0 to adapt to many kinds of systems. +\`configure' configures RcppArmadillo 0.12.8.2.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1291,7 +1291,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of RcppArmadillo 0.12.8.1.0:";; + short | recursive ) echo "Configuration of RcppArmadillo 0.12.8.2.0:";; esac cat <<\_ACEOF @@ -1372,7 +1372,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -RcppArmadillo configure 0.12.8.1.0 +RcppArmadillo configure 0.12.8.2.0 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -1486,7 +1486,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by RcppArmadillo $as_me 0.12.8.1.0, which was +It was created by RcppArmadillo $as_me 0.12.8.2.0, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3944,7 +3944,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by RcppArmadillo $as_me 0.12.8.1.0, which was +This file was extended by RcppArmadillo $as_me 0.12.8.2.0, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3999,7 +3999,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -RcppArmadillo config.status 0.12.8.1.0 +RcppArmadillo config.status 0.12.8.2.0 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 9675a541..383d60fc 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_PREREQ([2.69]) ## Process this file with autoconf to produce a configure script. -AC_INIT([RcppArmadillo],[0.12.8.1.0],[edd@debian.org]) +AC_INIT([RcppArmadillo],[0.12.8.2.0],[edd@debian.org]) ## Set R_HOME, respecting an environment variable if one is set : ${R_HOME=$(R RHOME)} diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 9852da7f..e2ef460c 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -3,6 +3,18 @@ \newcommand{\ghpr}{\href{https://github.com/RcppCore/RcppArmadillo/pull/#1}{##1}} \newcommand{\ghit}{\href{https://github.com/RcppCore/RcppArmadillo/issues/#1}{##1}} +\section{Changes in RcppArmadillo version 0.12.8.2.0 (2024-04-02)}{ + \itemize{ + \item Upgraded to Armadillo release 12.8.2 (Cortisol Injector) + \itemize{ + \item Workaround for FFTW3 header clash + \item Workaround in testing framework for issue under macOS + \item Minor cleanups to reduce code bloat + \item Improved documentation + } + } +} + \section{Changes in RcppArmadillo version 0.12.8.1.0 (2024-03-02)}{ \itemize{ \item Upgraded to Armadillo release 12.8.1 (Cortisol Injector) diff --git a/inst/include/armadillo_bits/Mat_meat.hpp b/inst/include/armadillo_bits/Mat_meat.hpp index cb92ffde..75e5c401 100644 --- a/inst/include/armadillo_bits/Mat_meat.hpp +++ b/inst/include/armadillo_bits/Mat_meat.hpp @@ -942,11 +942,19 @@ Mat::init(const std::initializer_list< std::initializer_list >& list) uword x_n_rows = uword(list.size()); uword x_n_cols = 0; + uword x_n_elem = 0; auto it = list.begin(); auto it_end = list.end(); - for(; it != it_end; ++it) { x_n_cols = (std::max)(x_n_cols, uword((*it).size())); } + for(; it != it_end; ++it) + { + const uword x_n_cols_new = uword((*it).size()); + + x_n_elem += x_n_cols_new; + + x_n_cols = (std::max)(x_n_cols, x_n_cols_new); + } Mat& t = (*this); @@ -959,6 +967,9 @@ Mat::init(const std::initializer_list< std::initializer_list >& list) t.set_size(x_n_rows, x_n_cols); } + // if the inner lists have varying number of elements, treat missing elements as zeros + if(t.n_elem != x_n_elem) { t.zeros(); } + uword row_num = 0; auto row_it = list.begin(); @@ -977,11 +988,6 @@ Mat::init(const std::initializer_list< std::initializer_list >& list) ++col_num; } - for(uword c=col_num; c < x_n_cols; ++c) - { - t.at(row_num, c) = eT(0); - } - ++row_num; } } @@ -6796,21 +6802,10 @@ Mat::set_size(const uword new_n_elem) { arma_extra_debug_sigprint(); - switch(vec_state) - { - case 0: - // fallthrough - case 1: - init_warm(new_n_elem, 1); - break; - - case 2: - init_warm(1, new_n_elem); - break; - - default: - ; - } + const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem); + const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 ); + + init_warm(new_n_rows, new_n_cols); return *this; } @@ -6854,23 +6849,10 @@ Mat::resize(const uword new_n_elem) { arma_extra_debug_sigprint(); - switch(vec_state) - { - case 0: - // fallthrough - case 1: - (*this).resize(new_n_elem, 1); - break; - - case 2: - (*this).resize(1, new_n_elem); - break; - - default: - ; - } + const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem); + const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 ); - return *this; + return (*this).resize(new_n_rows, new_n_cols); } diff --git a/inst/include/armadillo_bits/SpMat_bones.hpp b/inst/include/armadillo_bits/SpMat_bones.hpp index e96f1530..9a91e8bf 100644 --- a/inst/include/armadillo_bits/SpMat_bones.hpp +++ b/inst/include/armadillo_bits/SpMat_bones.hpp @@ -139,7 +139,7 @@ class SpMat : public SpBase< eT, SpMat > template inline SpMat& operator*=(const Op& expr); template inline SpMat& operator/=(const Op& expr); template inline SpMat& operator%=(const Op& expr); - + //! explicit specification of sparse +/- scalar template inline explicit SpMat(const SpToDOp& expr); diff --git a/inst/include/armadillo_bits/SpMat_meat.hpp b/inst/include/armadillo_bits/SpMat_meat.hpp index b8d51cf6..247348d1 100644 --- a/inst/include/armadillo_bits/SpMat_meat.hpp +++ b/inst/include/armadillo_bits/SpMat_meat.hpp @@ -3701,21 +3701,14 @@ SpMat::copy_size(const Mat& m) template inline SpMat& -SpMat::set_size(const uword in_elem) +SpMat::set_size(const uword new_n_elem) { arma_extra_debug_sigprint(); - // If this is a row vector, we resize to a row vector. - if(vec_state == 2) - { - set_size(1, in_elem); - } - else - { - set_size(in_elem, 1); - } + const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem); + const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 ); - return *this; + return set_size(new_n_rows, new_n_cols); } @@ -4115,20 +4108,14 @@ SpMat::zeros() template inline SpMat& -SpMat::zeros(const uword in_elem) +SpMat::zeros(const uword new_n_elem) { arma_extra_debug_sigprint(); - if(vec_state == 2) - { - zeros(1, in_elem); // Row vector - } - else - { - zeros(in_elem, 1); - } + const uword new_n_rows = (vec_state == 2) ? uword(1 ) : uword(new_n_elem); + const uword new_n_cols = (vec_state == 2) ? uword(new_n_elem) : uword(1 ); - return *this; + return zeros(new_n_rows, new_n_cols); } @@ -4432,12 +4419,10 @@ SpMat::reset() { arma_extra_debug_sigprint(); - switch(vec_state) - { - default: init(0, 0); break; - case 1: init(0, 1); break; - case 2: init(1, 0); break; - } + const uword new_n_rows = (vec_state == 2) ? 1 : 0; + const uword new_n_cols = (vec_state == 1) ? 1 : 0; + + init(new_n_rows, new_n_cols); } diff --git a/inst/include/armadillo_bits/arma_version.hpp b/inst/include/armadillo_bits/arma_version.hpp index 70f35c67..ed2c1844 100644 --- a/inst/include/armadillo_bits/arma_version.hpp +++ b/inst/include/armadillo_bits/arma_version.hpp @@ -23,7 +23,7 @@ #define ARMA_VERSION_MAJOR 12 #define ARMA_VERSION_MINOR 8 -#define ARMA_VERSION_PATCH 1 +#define ARMA_VERSION_PATCH 2 #define ARMA_VERSION_NAME "Cortisol Injector" diff --git a/inst/include/armadillo_bits/def_fftw3.hpp b/inst/include/armadillo_bits/def_fftw3.hpp index 454d7524..a2dce5f7 100644 --- a/inst/include/armadillo_bits/def_fftw3.hpp +++ b/inst/include/armadillo_bits/def_fftw3.hpp @@ -16,31 +16,38 @@ // ------------------------------------------------------------------------ -#if defined(ARMA_USE_FFTW3) +#if defined(ARMA_USE_FFTW3) && !defined(FFTW3_H) + + +// prefix for single precision: fftwf_ +// prefix for double precision: fftw_ + + +typedef void fftwf_complex; +typedef void fftw_complex; + +typedef void_ptr fftwf_plan; +typedef void_ptr fftw_plan; extern "C" { - // function prefix for single precision: fftwf_ - // function prefix for double precision: fftw_ - - // single precision (float) - void_ptr fftwf_plan_dft_1d(int N, void* input, void* output, int fftw3_sign, unsigned int fftw3_flags); + fftwf_plan fftwf_plan_dft_1d(int N, fftwf_complex* input, fftwf_complex* output, int fftw3_sign, unsigned int fftw3_flags); - void fftwf_execute(void_ptr plan); - void fftwf_destroy_plan(void_ptr plan); + void fftwf_execute(fftwf_plan plan); + void fftwf_destroy_plan(fftwf_plan plan); void fftwf_cleanup(); // double precision (double) - void_ptr fftw_plan_dft_1d(int N, void* input, void* output, int fftw3_sign, unsigned int fftw3_flags); + fftw_plan fftw_plan_dft_1d(int N, fftw_complex* input, fftw_complex* output, int fftw3_sign, unsigned int fftw3_flags); - void fftw_execute(void_ptr plan); - void fftw_destroy_plan(void_ptr plan); + void fftw_execute(fftw_plan plan); + void fftw_destroy_plan(fftw_plan plan); void fftw_cleanup(); } diff --git a/inst/include/armadillo_bits/translate_fftw3.hpp b/inst/include/armadillo_bits/translate_fftw3.hpp index 1edd7276..c2d11b27 100644 --- a/inst/include/armadillo_bits/translate_fftw3.hpp +++ b/inst/include/armadillo_bits/translate_fftw3.hpp @@ -30,12 +30,12 @@ namespace fftw3 if(is_cx_float::value) { - return fftwf_plan_dft_1d(N, (cx_float*)input, (cx_float*)output, fftw3_sign, fftw3_flags); + return fftwf_plan_dft_1d(N, (fftwf_complex*)(input), (fftwf_complex*)(output), fftw3_sign, fftw3_flags); } else if(is_cx_double::value) { - return fftw_plan_dft_1d(N, (cx_double*)input, (cx_double*)output, fftw3_sign, fftw3_flags); + return fftw_plan_dft_1d(N, (fftw_complex*)(input), (fftw_complex*)(output), fftw3_sign, fftw3_flags); } return nullptr; @@ -52,12 +52,12 @@ namespace fftw3 if(is_cx_float::value) { - fftwf_execute(plan); + fftwf_execute(fftwf_plan(plan)); } else if(is_cx_double::value) { - fftw_execute(plan); + fftw_execute(fftw_plan(plan)); } } @@ -72,12 +72,12 @@ namespace fftw3 if(is_cx_float::value) { - fftwf_destroy_plan(plan); + fftwf_destroy_plan(fftwf_plan(plan)); } else if(is_cx_double::value) { - fftw_destroy_plan(plan); + fftw_destroy_plan(fftw_plan(plan)); } } diff --git a/inst/include/armadillo_bits/wall_clock_bones.hpp b/inst/include/armadillo_bits/wall_clock_bones.hpp index 29c30142..1a1a4e27 100644 --- a/inst/include/armadillo_bits/wall_clock_bones.hpp +++ b/inst/include/armadillo_bits/wall_clock_bones.hpp @@ -34,9 +34,9 @@ class wall_clock private: - bool valid = false; - std::chrono::steady_clock::time_point chrono_time1; + + bool valid = false; }; diff --git a/inst/include/armadillo_bits/wall_clock_meat.hpp b/inst/include/armadillo_bits/wall_clock_meat.hpp index 54ed68a7..a45b88a2 100644 --- a/inst/include/armadillo_bits/wall_clock_meat.hpp +++ b/inst/include/armadillo_bits/wall_clock_meat.hpp @@ -24,6 +24,8 @@ inline wall_clock::wall_clock() { arma_extra_debug_sigprint(); + + chrono_time1 = std::chrono::steady_clock::now(); // warmup } @@ -43,6 +45,7 @@ wall_clock::tic() arma_extra_debug_sigprint(); chrono_time1 = std::chrono::steady_clock::now(); + valid = true; } @@ -54,18 +57,13 @@ wall_clock::toc() { arma_extra_debug_sigprint(); - if(valid) - { - const std::chrono::steady_clock::time_point chrono_time2 = std::chrono::steady_clock::now(); - - typedef std::chrono::duration duration_type; // TODO: check this - - const duration_type chrono_span = std::chrono::duration_cast< duration_type >(chrono_time2 - chrono_time1); - - return chrono_span.count(); - } + const std::chrono::steady_clock::time_point chrono_time2 = std::chrono::steady_clock::now(); + + typedef std::chrono::duration duration_type; // TODO: check this + + const duration_type chrono_span = std::chrono::duration_cast< duration_type >(chrono_time2 - chrono_time1); - return 0.0; + return (valid) ? double(chrono_span.count()) : double(0); }