Skip to content

Commit bb5aab7

Browse files
authored
Merge pull request #455 from RcppCore/feature/arma_64bit_enhancement
Enhance ARMA_64BIT_WORD support for icube
2 parents 678ca11 + 5df4c20 commit bb5aab7

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2024-09-29 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/RcppArmadillo/interface/RcppArmadilloAs.h: Add icube
4+
exporter specialisation under ARMA_64BIT_WORD case
5+
16
2024-09-11 Dirk Eddelbuettel <[email protected]>
27

38
* DESCRIPTION (Version, Date): RcppArmadillo 14.0.2-1 CRAN release

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: RcppArmadillo
22
Type: Package
33
Title: 'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library
4-
Version: 14.0.2-1
4+
Version: 14.0.2-1.1
55
Date: 2024-09-10
66
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]",
77
comment = c(ORCID = "0000-0001-6419-907X")),

inst/include/RcppArmadillo/interface/RcppArmadilloAs.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,31 @@ namespace traits {
483483
Rcpp::Vector<RTYPE> vec;
484484
};
485485

486-
// specializations for 3 cube typedefs that fail above
487-
// first use viable conversion SEXP -> Cube<other_t>
486+
// specializations for 3 (or 4, see below) cube typedefs that
487+
// fail above first use viable conversion SEXP -> Cube<other_t>
488488
// then use conv_to<cube_t>::from(other_t other)
489+
#ifdef ARMA_64BIT_WORD
490+
// if we use ARMA_64BIT_WORD we cannot pass int through and
491+
// need a fourth specialization similar to the other three
492+
template <>
493+
class Exporter<arma::icube> {
494+
public:
495+
typedef arma::icube cube_t;
496+
497+
Exporter(SEXP x)
498+
: tmp(Exporter<arma::cube>(x).get()) {}
499+
500+
cube_t get() {
501+
cube_t result = arma::conv_to<cube_t>::from(tmp);
502+
return result;
503+
}
504+
505+
private:
506+
typedef arma::cube other_t;
507+
other_t tmp;
508+
};
509+
#endif
510+
489511
template <>
490512
class Exporter<arma::fcube> {
491513
public:

inst/tinytest/test_rng.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ expect_true(max(a) < 1)#, msg="randu max")
5252
set.seed(123)
5353
a <- randi(10)
5454
expect_true(min(a) > 0)#, msg="randi min")
55-
expect_true(typeof(a) == "integer")#, msg="randi type")
55+
## under ARMA_64BIT_WORD we get 'double'
56+
expect_true(typeof(a) == "integer" || typeof(a) == "double")#, msg="randi type")
5657

5758
#test.randn <- function() {
5859
set.seed(123)

0 commit comments

Comments
 (0)