From 8feb41101fe9b9466f84fbab02dd9c285a470876 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Wed, 29 May 2024 06:50:59 -0500 Subject: [PATCH 1/2] Armadillo 12.8.4-rc1 --- inst/include/armadillo | 6 ++--- .../include/armadillo_bits/SpSubview_meat.hpp | 26 +++++++++++++------ inst/include/armadillo_bits/fn_conv_to.hpp | 2 +- inst/include/armadillo_bits/fn_dot.hpp | 22 ++++++++++++++-- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/inst/include/armadillo b/inst/include/armadillo index ed4ed3f5..b5c888f1 100644 --- a/inst/include/armadillo +++ b/inst/include/armadillo @@ -19,9 +19,9 @@ #ifndef ARMA_INCLUDES #define ARMA_INCLUDES -// NOTE: functions that are designed to be user accessible are described in the documentation (docs.html). -// NOTE: all other functions and classes (ie. not explicitly described in the documentation) -// NOTE: are considered as internal implementation details, and may be changed or removed without notice. +// WARNING: the documentation (docs.html) describes the public API (functions, classes, constants); +// WARNING: any functionality which is _not explicitly_ described in the documentation +// WARNING: is considered as internal implementation detail, and may be changed or removed without notice. #include "armadillo_bits/config.hpp" #include "armadillo_bits/compiler_check.hpp" diff --git a/inst/include/armadillo_bits/SpSubview_meat.hpp b/inst/include/armadillo_bits/SpSubview_meat.hpp index 481359be..a598f21a 100644 --- a/inst/include/armadillo_bits/SpSubview_meat.hpp +++ b/inst/include/armadillo_bits/SpSubview_meat.hpp @@ -44,18 +44,28 @@ SpSubview::SpSubview(const SpMat& in_m, const uword in_row1, const uword m.sync_csc(); - // There must be a O(1) way to do this - uword lend = m.col_ptrs[in_col1 + in_n_cols]; - uword lend_row = in_row1 + in_n_rows; - uword count = 0; + // count the number of non-zeros in the subview + uword count = 0; - for(uword i = m.col_ptrs[in_col1]; i < lend; ++i) + if(n_rows == m.n_rows) { - const uword m_row_indices_i = m.row_indices[i]; + count = m.col_ptrs[aux_col1 + n_cols] - m.col_ptrs[aux_col1]; + } + else + { + arma_extra_debug_print("counting non-zeros in sparse subview"); - const bool condition = (m_row_indices_i >= in_row1) && (m_row_indices_i < lend_row); + uword lend = m.col_ptrs[in_col1 + in_n_cols]; + uword lend_row = in_row1 + in_n_rows; - count += condition ? uword(1) : uword(0); + for(uword i = m.col_ptrs[in_col1]; i < lend; ++i) + { + const uword m_row_indices_i = m.row_indices[i]; + + const bool condition = (m_row_indices_i >= in_row1) && (m_row_indices_i < lend_row); + + count += condition ? uword(1) : uword(0); + } } access::rw(n_nonzero) = count; diff --git a/inst/include/armadillo_bits/fn_conv_to.hpp b/inst/include/armadillo_bits/fn_conv_to.hpp index 4e2ed593..d59f1846 100644 --- a/inst/include/armadillo_bits/fn_conv_to.hpp +++ b/inst/include/armadillo_bits/fn_conv_to.hpp @@ -30,7 +30,7 @@ class conv_to template inline static out_eT from(const Base& in, const typename arma_not_cx::result* junk = nullptr); - + template inline static out_eT from(const Base& in, const typename arma_cx_only::result* junk = nullptr); diff --git a/inst/include/armadillo_bits/fn_dot.hpp b/inst/include/armadillo_bits/fn_dot.hpp index d2cbfc81..e8bb0dc7 100644 --- a/inst/include/armadillo_bits/fn_dot.hpp +++ b/inst/include/armadillo_bits/fn_dot.hpp @@ -289,13 +289,31 @@ dot { arma_extra_debug_sigprint(); + typedef typename T1::elem_type eT; + + if(is_SpSubview_col::value) + { + // TODO: refactor to use C++17 "if constexpr" to avoid reinterpret_cast shenanigans + + const SpSubview_col& yy = reinterpret_cast< const SpSubview_col& >(y); + + if(yy.n_rows == yy.m.n_rows) + { + arma_extra_debug_print("using sparse column vector specialisation"); + + const quasi_unwrap U(x); + + arma_debug_assert_same_size(U.M.n_elem, uword(1), yy.n_elem, uword(1), "dot()"); + + return dense_sparse_helper::dot(U.M.memptr(), yy.m, yy.aux_col1); + } + } + const Proxy pa(x); const SpProxy pb(y); arma_debug_assert_same_size(pa.get_n_rows(), pa.get_n_cols(), pb.get_n_rows(), pb.get_n_cols(), "dot()"); - typedef typename T1::elem_type eT; - eT result = eT(0); typename SpProxy::const_iterator_type it = pb.begin(); From 8c8202ce6aea94e6b0116c193de14d7eef54e69f Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Wed, 29 May 2024 06:54:02 -0500 Subject: [PATCH 2/2] RcppArmadillo 0.12.8.3.1 with 12.8.4-rc1 --- ChangeLog | 10 ++++++++++ DESCRIPTION | 4 ++-- configure | 18 +++++++++--------- configure.ac | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49e8d0d7..0a0dfc24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2024-05-29 Dirk Eddelbuettel + + * DESCRIPTION (Version, Date): RcppArmadillo 0.12.8.3.1 + * inst/NEWS.Rd: Idem + * configure.ac: Idem + +2024-05-26 Dirk Eddelbuettel + + * inst/include/armadillo_bits/: Armadillo 12.8.4-rc1 + 2024-05-17 Dirk Eddelbuettel * DESCRIPTION (Imports): Updated versioned constraint on Rcpp to diff --git a/DESCRIPTION b/DESCRIPTION index c1f92345..59665671 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.3.0 -Date: 2024-05-07 +Version: 0.12.8.3.1 +Date: 2024-05-26 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/configure b/configure index 3185119e..c597aafb 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.3.0. +# Generated by GNU Autoconf 2.71 for RcppArmadillo 0.12.8.3.1. # # Report bugs to . # @@ -610,8 +610,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='RcppArmadillo' PACKAGE_TARNAME='rcpparmadillo' -PACKAGE_VERSION='0.12.8.3.0' -PACKAGE_STRING='RcppArmadillo 0.12.8.3.0' +PACKAGE_VERSION='0.12.8.3.1' +PACKAGE_STRING='RcppArmadillo 0.12.8.3.1' 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.3.0 to adapt to many kinds of systems. +\`configure' configures RcppArmadillo 0.12.8.3.1 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.3.0:";; + short | recursive ) echo "Configuration of RcppArmadillo 0.12.8.3.1:";; 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.3.0 +RcppArmadillo configure 0.12.8.3.1 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.3.0, which was +It was created by RcppArmadillo $as_me 0.12.8.3.1, 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.3.0, which was +This file was extended by RcppArmadillo $as_me 0.12.8.3.1, 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.3.0 +RcppArmadillo config.status 0.12.8.3.1 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 00318220..e1a03b6c 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.3.0],[edd@debian.org]) +AC_INIT([RcppArmadillo],[0.12.8.3.1],[edd@debian.org]) ## Set R_HOME, respecting an environment variable if one is set : ${R_HOME=$(R RHOME)}