Skip to content

Commit 93cd6e5

Browse files
authored
Merge pull request #435 from RcppCore/feature/armadillo_12.8.1
RcppArmadillo 0.12.8.1.0
2 parents 70dc05e + 8abe7be commit 93cd6e5

File tree

9 files changed

+93
-51
lines changed

9 files changed

+93
-51
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: RcppArmadillo
22
Type: Package
33
Title: 'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library
4-
Version: 0.12.8.0.0.1
5-
Date: 2024-02-19
4+
Version: 0.12.8.1.0
5+
Date: 2024-03-02
66
Author: Dirk Eddelbuettel, Romain Francois, Doug Bates, Binxiang Ni, and Conrad Sanderson
77
Maintainer: Dirk Eddelbuettel <[email protected]>
88
Description: 'Armadillo' is a templated C++ linear algebra library (by Conrad

configure

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.71 for RcppArmadillo 0.12.8.0.0.
3+
# Generated by GNU Autoconf 2.71 for RcppArmadillo 0.12.8.1.0.
44
#
55
# Report bugs to <[email protected]>.
66
#
@@ -610,8 +610,8 @@ MAKEFLAGS=
610610
# Identity of this package.
611611
PACKAGE_NAME='RcppArmadillo'
612612
PACKAGE_TARNAME='rcpparmadillo'
613-
PACKAGE_VERSION='0.12.8.0.0'
614-
PACKAGE_STRING='RcppArmadillo 0.12.8.0.0'
613+
PACKAGE_VERSION='0.12.8.1.0'
614+
PACKAGE_STRING='RcppArmadillo 0.12.8.1.0'
615615
PACKAGE_BUGREPORT='[email protected]'
616616
PACKAGE_URL=''
617617

@@ -1229,7 +1229,7 @@ if test "$ac_init_help" = "long"; then
12291229
# Omit some internal or obsolete options to make the list less imposing.
12301230
# This message is too long to be a string in the A/UX 3.1 sh.
12311231
cat <<_ACEOF
1232-
\`configure' configures RcppArmadillo 0.12.8.0.0 to adapt to many kinds of systems.
1232+
\`configure' configures RcppArmadillo 0.12.8.1.0 to adapt to many kinds of systems.
12331233
12341234
Usage: $0 [OPTION]... [VAR=VALUE]...
12351235
@@ -1291,7 +1291,7 @@ fi
12911291

12921292
if test -n "$ac_init_help"; then
12931293
case $ac_init_help in
1294-
short | recursive ) echo "Configuration of RcppArmadillo 0.12.8.0.0:";;
1294+
short | recursive ) echo "Configuration of RcppArmadillo 0.12.8.1.0:";;
12951295
esac
12961296
cat <<\_ACEOF
12971297
@@ -1372,7 +1372,7 @@ fi
13721372
test -n "$ac_init_help" && exit $ac_status
13731373
if $ac_init_version; then
13741374
cat <<\_ACEOF
1375-
RcppArmadillo configure 0.12.8.0.0
1375+
RcppArmadillo configure 0.12.8.1.0
13761376
generated by GNU Autoconf 2.71
13771377
13781378
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1486,7 +1486,7 @@ cat >config.log <<_ACEOF
14861486
This file contains any messages produced by compilers while
14871487
running configure, to aid debugging if configure makes a mistake.
14881488
1489-
It was created by RcppArmadillo $as_me 0.12.8.0.0, which was
1489+
It was created by RcppArmadillo $as_me 0.12.8.1.0, which was
14901490
generated by GNU Autoconf 2.71. Invocation command line was
14911491
14921492
$ $0$ac_configure_args_raw
@@ -3944,7 +3944,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
39443944
# report actual input values of CONFIG_FILES etc. instead of their
39453945
# values after options handling.
39463946
ac_log="
3947-
This file was extended by RcppArmadillo $as_me 0.12.8.0.0, which was
3947+
This file was extended by RcppArmadillo $as_me 0.12.8.1.0, which was
39483948
generated by GNU Autoconf 2.71. Invocation command line was
39493949
39503950
CONFIG_FILES = $CONFIG_FILES
@@ -3999,7 +3999,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
39993999
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
40004000
ac_cs_config='$ac_cs_config_escaped'
40014001
ac_cs_version="\\
4002-
RcppArmadillo config.status 0.12.8.0.0
4002+
RcppArmadillo config.status 0.12.8.1.0
40034003
configured by $0, generated by GNU Autoconf 2.71,
40044004
with options \\"\$ac_cs_config\\"
40054005

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
AC_PREREQ([2.69])
1212

1313
## Process this file with autoconf to produce a configure script.
14-
AC_INIT([RcppArmadillo],[0.12.8.0.0],[[email protected]])
14+
AC_INIT([RcppArmadillo],[0.12.8.1.0],[[email protected]])
1515

1616
## Set R_HOME, respecting an environment variable if one is set
1717
: ${R_HOME=$(R RHOME)}

inst/NEWS.Rd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
\newcommand{\ghpr}{\href{https://github.com/RcppCore/RcppArmadillo/pull/#1}{##1}}
44
\newcommand{\ghit}{\href{https://github.com/RcppCore/RcppArmadillo/issues/#1}{##1}}
55

6+
\section{Changes in RcppArmadillo version 0.12.8.1.0 (2024-03-02)}{
7+
\itemize{
8+
\item Upgraded to Armadillo release 12.8.1 (Cortisol Injector)
9+
\itemize{
10+
\item Workaround in \code{norm()} for yet another bug in macOS
11+
accelerate framework
12+
}
13+
\item Update README for RcppArmadillo usage counts
14+
\item Update examples to use '#include <RcppArmadillo/Lighter>' for
15+
faster compilation excluding unused Rcpp features
16+
}
17+
}
18+
619
\section{Changes in RcppArmadillo version 0.12.8.0.0 (2024-02-06)}{
720
\itemize{
821
\item Upgraded to Armadillo release 12.8.0 (Cortisol Injector)

inst/include/armadillo_bits/arma_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define ARMA_VERSION_MAJOR 12
2525
#define ARMA_VERSION_MINOR 8
26-
#define ARMA_VERSION_PATCH 0
26+
#define ARMA_VERSION_PATCH 1
2727
#define ARMA_VERSION_NAME "Cortisol Injector"
2828

2929

inst/include/armadillo_bits/compiler_setup.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115

116116
#if defined(__APPLE__) || defined(__apple_build_version__)
117117
// NOTE: Apple accelerate framework has broken implementations of functions that return a float value,
118-
// NOTE: such as sdot(), slange(), clange(), slansy(), clanhe(), slangb()
118+
// NOTE: such as sdot(), slange(), clange(), slansy(), clanhe(), slangb(), snrm2(), sasum()
119119
#undef ARMA_BLAS_FLOAT_BUG
120120
#define ARMA_BLAS_FLOAT_BUG
121121

inst/include/armadillo_bits/op_norm_meat.hpp

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ op_norm::vec_norm_1(const Proxy<T1>& P, const typename arma_cx_only<typename T1:
174174
}
175175
else
176176
{
177-
arma_extra_debug_print("op_norm::vec_norm_1(): detected possible underflow or overflow");
177+
arma_extra_debug_print("detected possible underflow or overflow");
178178

179179
const quasi_unwrap<typename Proxy<T1>::stored_type> R(P.Q);
180180

@@ -224,26 +224,32 @@ op_norm::vec_norm_1_direct_std(const Mat<eT>& X)
224224
const uword N = X.n_elem;
225225
const eT* A = X.memptr();
226226

227-
if(N < uword(32))
227+
eT out_val = eT(0);
228+
229+
#if defined(ARMA_USE_ATLAS)
228230
{
229-
return op_norm::vec_norm_1_direct_mem(N,A);
231+
arma_extra_debug_print("atlas::cblas_asum()");
232+
out_val = atlas::cblas_asum(N,A);
230233
}
231-
else
234+
#elif defined(ARMA_USE_BLAS)
232235
{
233-
#if defined(ARMA_USE_ATLAS)
234-
{
235-
return atlas::cblas_asum(N,A);
236-
}
237-
#elif defined(ARMA_USE_BLAS)
236+
if(has_blas_float_bug<eT>::value)
238237
{
239-
return blas::asum(N,A);
238+
out_val = op_norm::vec_norm_1_direct_mem(N,A);
240239
}
241-
#else
240+
else
242241
{
243-
return op_norm::vec_norm_1_direct_mem(N,A);
242+
arma_extra_debug_print("blas::asum()");
243+
out_val = blas::asum(N,A);
244244
}
245-
#endif
246245
}
246+
#else
247+
{
248+
out_val = op_norm::vec_norm_1_direct_mem(N,A);
249+
}
250+
#endif
251+
252+
return (out_val <= eT(0)) ? eT(0) : out_val;
247253
}
248254

249255

@@ -397,7 +403,7 @@ op_norm::vec_norm_2(const Proxy<T1>& P, const typename arma_not_cx<typename T1::
397403
}
398404
else
399405
{
400-
arma_extra_debug_print("op_norm::vec_norm_2(): detected possible underflow or overflow");
406+
arma_extra_debug_print("detected possible underflow or overflow");
401407

402408
const quasi_unwrap<typename Proxy<T1>::stored_type> tmp(P.Q);
403409

@@ -476,7 +482,7 @@ op_norm::vec_norm_2(const Proxy<T1>& P, const typename arma_cx_only<typename T1:
476482
}
477483
else
478484
{
479-
arma_extra_debug_print("op_norm::vec_norm_2(): detected possible underflow or overflow");
485+
arma_extra_debug_print("detected possible underflow or overflow");
480486

481487
const quasi_unwrap<typename Proxy<T1>::stored_type> R(P.Q);
482488

@@ -519,36 +525,38 @@ op_norm::vec_norm_2_direct_std(const Mat<eT>& X)
519525
const uword N = X.n_elem;
520526
const eT* A = X.memptr();
521527

522-
eT result;
528+
eT out_val = eT(0);
523529

524-
if(N < uword(32))
530+
#if defined(ARMA_USE_ATLAS)
525531
{
526-
result = op_norm::vec_norm_2_direct_mem(N,A);
532+
arma_extra_debug_print("atlas::cblas_nrm2()");
533+
out_val = atlas::cblas_nrm2(N,A);
527534
}
528-
else
535+
#elif defined(ARMA_USE_BLAS)
529536
{
530-
#if defined(ARMA_USE_ATLAS)
537+
if(has_blas_float_bug<eT>::value)
531538
{
532-
result = atlas::cblas_nrm2(N,A);
539+
out_val = op_norm::vec_norm_2_direct_mem(N,A);
533540
}
534-
#elif defined(ARMA_USE_BLAS)
535-
{
536-
result = blas::nrm2(N,A);
537-
}
538-
#else
541+
else
539542
{
540-
result = op_norm::vec_norm_2_direct_mem(N,A);
543+
arma_extra_debug_print("blas::nrm2()");
544+
out_val = blas::nrm2(N,A);
541545
}
542-
#endif
543546
}
547+
#else
548+
{
549+
out_val = op_norm::vec_norm_2_direct_mem(N,A);
550+
}
551+
#endif
544552

545-
if( (result != eT(0)) && arma_isfinite(result) )
553+
if( (out_val != eT(0)) && arma_isfinite(out_val) )
546554
{
547-
return result;
555+
return (out_val < eT(0)) ? eT(0) : out_val;
548556
}
549557
else
550558
{
551-
arma_extra_debug_print("op_norm::vec_norm_2_direct_std(): detected possible underflow or overflow");
559+
arma_extra_debug_print("detected possible underflow or overflow");
552560

553561
return op_norm::vec_norm_2_direct_robust(X);
554562
}
@@ -563,7 +571,7 @@ op_norm::vec_norm_2_direct_mem(const uword N, const eT* A)
563571
{
564572
arma_extra_debug_sigprint();
565573

566-
eT acc;
574+
eT acc = eT(0);
567575

568576
#if (defined(ARMA_SIMPLE_LOOPS) || defined(__FAST_MATH__))
569577
{
@@ -673,7 +681,9 @@ op_norm::vec_norm_2_direct_robust(const Mat<eT>& X)
673681
acc1 += val_i * val_i;
674682
}
675683

676-
return ( std::sqrt(acc1 + acc2) * max_val );
684+
const eT out_val = std::sqrt(acc1 + acc2) * max_val;
685+
686+
return (out_val <= eT(0)) ? eT(0) : out_val;
677687
}
678688

679689

@@ -882,9 +892,12 @@ op_norm::mat_norm_2(const Mat<eT>& X)
882892
if(X.internal_has_nonfinite()) { arma_debug_warn_level(1, "norm(): given matrix has non-finite elements"); }
883893

884894
Col<T> S;
895+
885896
svd(S, X);
886897

887-
return (S.n_elem > 0) ? S[0] : T(0);
898+
const T out_val = (S.n_elem > 0) ? S[0] : T(0);
899+
900+
return (out_val <= T(0)) ? T(0) : out_val;
888901
}
889902

890903

inst/include/armadillo_bits/spop_norm_meat.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ spop_norm::mat_norm_2(const SpMat<eT>& X, const typename arma_real_only<eT>::res
5353
const SpMat<eT> C = (A.n_rows <= A.n_cols) ? (A*B) : (B*A);
5454

5555
Col<T> eigval;
56+
5657
eigs_sym(eigval, C, 1);
5758

58-
return (eigval.n_elem > 0) ? T(std::sqrt(eigval[0])) : T(0);
59+
const T out_square_val = (eigval.n_elem > 0) ? T(eigval[0]) : T(0);
60+
61+
return (out_square_val <= T(0)) ? T(0) : T(std::sqrt(out_square_val));
5962
}
6063

6164

@@ -84,9 +87,12 @@ spop_norm::mat_norm_2(const SpMat<eT>& X, const typename arma_cx_only<eT>::resul
8487
const SpMat<eT> C = (A.n_rows <= A.n_cols) ? (A*B) : (B*A);
8588

8689
Col<eT> eigval;
90+
8791
eigs_gen(eigval, C, 1);
8892

89-
return (eigval.n_elem > 0) ? T(std::sqrt(std::real(eigval[0]))) : T(0);
93+
const T out_square_val = (eigval.n_elem > 0) ? T(std::real(eigval[0])) : T(0);
94+
95+
return (out_square_val <= T(0)) ? T(0) : T(std::sqrt(out_square_val));
9096
}
9197

9298

inst/include/armadillo_bits/translate_blas.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ namespace blas
145145

146146
eT result[2]; // paranoia: using two elements instead of one
147147

148+
result[0] = eT(0);
149+
result[1] = eT(0);
150+
148151
blas::gemv(&trans, &m, &n, &alpha, x, &m, y, &inc, &beta, &result[0], &inc);
149152

150153
return result[0];
@@ -186,11 +189,14 @@ namespace blas
186189

187190
eT result[2]; // paranoia: using two elements instead of one
188191

192+
result[0] = eT(0);
193+
result[1] = eT(0);
194+
189195
blas::gemv(&trans, &m, &n, &alpha, x, &m, y, &inc, &beta, &result[0], &inc);
190196

191197
return result[0];
192198
}
193-
199+
194200
return eT(0);
195201
}
196202

@@ -205,6 +211,8 @@ namespace blas
205211

206212
if(is_float<eT>::value)
207213
{
214+
// WARNING: sasum() from Accelerate framework (macOS) may return 'double' instead of 'float'
215+
208216
blas_int n = blas_int(n_elem);
209217
blas_int inc = 1;
210218

@@ -235,6 +243,8 @@ namespace blas
235243

236244
if(is_float<eT>::value)
237245
{
246+
// WARNING: snrm2() from Accelerate framework (macOS) may return 'double' instead of 'float'
247+
238248
blas_int n = blas_int(n_elem);
239249
blas_int inc = 1;
240250

0 commit comments

Comments
 (0)