Skip to content

Commit

Permalink
Merge pull request #455 from RcppCore/feature/arma_64bit_enhancement
Browse files Browse the repository at this point in the history
Enhance ARMA_64BIT_WORD support for icube
  • Loading branch information
eddelbuettel authored Oct 10, 2024
2 parents 678ca11 + 5df4c20 commit bb5aab7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-09-29 Dirk Eddelbuettel <[email protected]>

* inst/include/RcppArmadillo/interface/RcppArmadilloAs.h: Add icube
exporter specialisation under ARMA_64BIT_WORD case

2024-09-11 Dirk Eddelbuettel <[email protected]>

* DESCRIPTION (Version, Date): RcppArmadillo 14.0.2-1 CRAN release
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: RcppArmadillo
Type: Package
Title: 'Rcpp' Integration for the 'Armadillo' Templated Linear Algebra Library
Version: 14.0.2-1
Version: 14.0.2-1.1
Date: 2024-09-10
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "[email protected]",
comment = c(ORCID = "0000-0001-6419-907X")),
Expand Down
26 changes: 24 additions & 2 deletions inst/include/RcppArmadillo/interface/RcppArmadilloAs.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,31 @@ namespace traits {
Rcpp::Vector<RTYPE> vec;
};

// specializations for 3 cube typedefs that fail above
// first use viable conversion SEXP -> Cube<other_t>
// specializations for 3 (or 4, see below) cube typedefs that
// fail above first use viable conversion SEXP -> Cube<other_t>
// then use conv_to<cube_t>::from(other_t other)
#ifdef ARMA_64BIT_WORD
// if we use ARMA_64BIT_WORD we cannot pass int through and
// need a fourth specialization similar to the other three
template <>
class Exporter<arma::icube> {
public:
typedef arma::icube cube_t;

Exporter(SEXP x)
: tmp(Exporter<arma::cube>(x).get()) {}

cube_t get() {
cube_t result = arma::conv_to<cube_t>::from(tmp);
return result;
}

private:
typedef arma::cube other_t;
other_t tmp;
};
#endif

template <>
class Exporter<arma::fcube> {
public:
Expand Down
3 changes: 2 additions & 1 deletion inst/tinytest/test_rng.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ expect_true(max(a) < 1)#, msg="randu max")
set.seed(123)
a <- randi(10)
expect_true(min(a) > 0)#, msg="randi min")
expect_true(typeof(a) == "integer")#, msg="randi type")
## under ARMA_64BIT_WORD we get 'double'
expect_true(typeof(a) == "integer" || typeof(a) == "double")#, msg="randi type")

#test.randn <- function() {
set.seed(123)
Expand Down

0 comments on commit bb5aab7

Please sign in to comment.