Skip to content

Commit 554e7c1

Browse files
committed
Add armadillo_version_typed() helper
1 parent d947d71 commit 554e7c1

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2025-10-17 Dirk Eddelbuettel <[email protected]>
2+
3+
* src/RcppArmadillo.cpp (armadillo_version_typed): Added
4+
* man/armadillo_version.Rd: Documentation added
5+
* src/RcppExports.cpp: Regenerated
6+
* R/RcppExports.R: Idem
7+
* NAMESPACE: Exported
8+
19
2025-10-16 Dirk Eddelbuettel <[email protected]>
210

311
* DESCRIPTION (Version, Date): RcppArmadillo 15.1.99-1

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export("fastLmPure",
99
"fastLm",
1010
"RcppArmadillo.package.skeleton",
1111
"armadillo_version",
12+
"armadillo_version_typed",
1213
"armadillo_set_seed",
1314
"armadillo_set_seed_random",
1415

R/RcppExports.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@
88
#' or a named vector with three elements \code{major}, \code{minor} and \code{patch}.
99
#' @return Depending on the value of \code{single}, either a single number describing
1010
#' the Armadillo version or a named vector with three elements \code{major}, \code{minor}
11-
#' and \code{patch}.
11+
#' and \code{patch}. The function \code{armadillo_version_typed} returns an S3 object
12+
#' of classes \sQuote{package_version} and \sQuote{numeric_version} which offer comparison
13+
#' and formatting operators.
1214
#' @seealso Armadillo header file \code{arma_version.hpp}.
1315
armadillo_version <- function(single) {
1416
.Call(`_RcppArmadillo_armadillo_version`, single)
1517
}
1618

19+
#' @rdname armadillo_version
20+
armadillo_version_typed <- function() {
21+
.Call(`_RcppArmadillo_armadillo_version_typed`)
22+
}
23+
1724
#' @rdname armadillo_set_seed
1825
armadillo_set_seed_random <- function() {
1926
invisible(.Call(`_RcppArmadillo_armadillo_set_seed_random`))

man/armadillo_version.Rd

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/RcppArmadillo.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
//' or a named vector with three elements \code{major}, \code{minor} and \code{patch}.
2828
//' @return Depending on the value of \code{single}, either a single number describing
2929
//' the Armadillo version or a named vector with three elements \code{major}, \code{minor}
30-
//' and \code{patch}.
30+
//' and \code{patch}. The function \code{armadillo_version_typed} returns an S3 object
31+
//' of classes \sQuote{package_version} and \sQuote{numeric_version} which offer comparison
32+
//' and formatting operators.
3133
//' @seealso Armadillo header file \code{arma_version.hpp}.
3234
// [[Rcpp::export]]
3335
Rcpp::IntegerVector armadillo_version(bool single) {
@@ -47,6 +49,18 @@ Rcpp::IntegerVector armadillo_version(bool single) {
4749
}
4850
}
4951

52+
//' @rdname armadillo_version
53+
// [[Rcpp::export]]
54+
Rcpp::List armadillo_version_typed() {
55+
// create a vector of major, minor, patch
56+
auto ver = Rcpp::IntegerVector::create(ARMA_VERSION_MAJOR, ARMA_VERSION_MINOR, ARMA_VERSION_PATCH);
57+
// and place it in a list (as e.g. packageVersion() in R returns)
58+
auto lst = Rcpp::List::create(ver);
59+
// and class it as 'package_version' accessing print() etc methods
60+
lst.attr("class") = Rcpp::CharacterVector::create("package_version", "numeric_version");
61+
return lst;
62+
}
63+
5064
// Per request of Gábor Csárdi in https://github.com/RcppCore/RcppArmadillo/issues/11
5165
//
5266
//' @rdname armadillo_set_seed

src/RcppExports.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ BEGIN_RCPP
2222
return rcpp_result_gen;
2323
END_RCPP
2424
}
25+
// armadillo_version_typed
26+
Rcpp::List armadillo_version_typed();
27+
RcppExport SEXP _RcppArmadillo_armadillo_version_typed() {
28+
BEGIN_RCPP
29+
Rcpp::RObject rcpp_result_gen;
30+
Rcpp::RNGScope rcpp_rngScope_gen;
31+
rcpp_result_gen = Rcpp::wrap(armadillo_version_typed());
32+
return rcpp_result_gen;
33+
END_RCPP
34+
}
2535
// armadillo_set_seed_random
2636
void armadillo_set_seed_random();
2737
RcppExport SEXP _RcppArmadillo_armadillo_set_seed_random() {
@@ -76,6 +86,7 @@ END_RCPP
7686

7787
static const R_CallMethodDef CallEntries[] = {
7888
{"_RcppArmadillo_armadillo_version", (DL_FUNC) &_RcppArmadillo_armadillo_version, 1},
89+
{"_RcppArmadillo_armadillo_version_typed", (DL_FUNC) &_RcppArmadillo_armadillo_version_typed, 0},
7990
{"_RcppArmadillo_armadillo_set_seed_random", (DL_FUNC) &_RcppArmadillo_armadillo_set_seed_random, 0},
8091
{"_RcppArmadillo_armadillo_set_seed", (DL_FUNC) &_RcppArmadillo_armadillo_set_seed, 1},
8192
{"_RcppArmadillo_armadillo_get_number_of_omp_threads", (DL_FUNC) &_RcppArmadillo_armadillo_get_number_of_omp_threads, 0},

0 commit comments

Comments
 (0)