32
32
// [[Rcpp::export]]
33
33
Rcpp::IntegerVector armadillo_version (bool single) {
34
34
35
+ // These are declared as constexpr in Armadillo which actually does not define them
36
+ // They are also defined as macros in arma_version.hpp so we just use that
37
+ const unsigned int major = ARMA_VERSION_MAJOR;
38
+ const unsigned int minor = ARMA_VERSION_MINOR;
39
+ const unsigned int patch = ARMA_VERSION_PATCH;
40
+
35
41
if (single) {
36
- return Rcpp::wrap (10000 *arma::arma_version::major +
37
- 100 *arma::arma_version::minor +
38
- arma::arma_version::patch) ;
42
+ return Rcpp::wrap (10000 * major + 100 * minor + patch) ;
43
+ } else {
44
+ return Rcpp::IntegerVector::create (Rcpp::Named (" major" ) = major,
45
+ Rcpp::Named (" minor" ) = minor,
46
+ Rcpp::Named (" patch" ) = patch);
39
47
}
40
-
41
- Rcpp::IntegerVector version =
42
- Rcpp::IntegerVector::create (Rcpp::Named (" major" ) = arma::arma_version::major,
43
- Rcpp::Named (" minor" ) = arma::arma_version::minor,
44
- Rcpp::Named (" patch" ) = arma::arma_version::patch);
45
-
46
- return version ;
47
48
}
48
49
49
50
// Per request of Gábor Csárdi in https://github.com/RcppCore/RcppArmadillo/issues/11
50
51
//
51
52
// ' Set the Armadillo Random Number Generator to a random value
52
- // '
53
+ // '
53
54
// ' @details
54
55
// ' Depending on whether RcppArmadillo was compiled for the C++98 standard
55
56
// ' (currently the default) or for C++11 (optional), two different RNGs may be used.
@@ -60,32 +61,32 @@ Rcpp::IntegerVector armadillo_version(bool single) {
60
61
// ' @return The function is invoked for its side effect and has no return value.
61
62
// ' @note This has been found to not work as espected in \pkg{RStudio}
62
63
// ' as its code also uses the system RNG library. You may have to either
63
- // ' not run within \pkg{RStudio} or change your code to use a different RNG such
64
+ // ' not run within \pkg{RStudio} or change your code to use a different RNG such
64
65
// ' as the one from R.
65
- // ' @seealso The R documentation on its RNGs all of which are accessible via \pkg{Rcpp}.
66
+ // ' @seealso The R documentation on its RNGs all of which are accessible via \pkg{Rcpp}.
66
67
// [[Rcpp::export]]
67
68
void armadillo_set_seed_random () {
68
69
arma::arma_rng::set_seed_random (); // set the seed to a random value
69
- }
70
+ }
70
71
71
72
// ' Set the Armadillo Random Number Generator to the given value
72
- // '
73
+ // '
73
74
// ' @param val The seed used to initialize Armadillo's random number generator.
74
- // ' @details
75
+ // ' @details
75
76
// ' Depending on whether RcppArmadillo was compiled for the C++98 standard
76
77
// ' (currently the default) or for C++11 (optional), two different RNGs may be used.
77
78
// ' This function resets either. For C++98, the R programming language's RNG is used.
78
79
// ' For C++11, the RNG included in the \code{<random>} library is used only when
79
80
// ' \code{#define ARMA_USE_CXX11_RNG} is placed before \code{#include <RcppArmadillo.h>}.
80
81
// ' Otherwise, the R programming language's RNG will be used.
81
- // ' @return The function is invoked for its side effect and has no return value.
82
+ // ' @return The function is invoked for its side effect and has no return value.
82
83
// ' @note This has been found to not work as espected in \pkg{RStudio}
83
84
// ' as its code also uses the system RNG library. You may have to either
84
- // ' not run within \pkg{RStudio} or change your code to use a different RNG such
85
+ // ' not run within \pkg{RStudio} or change your code to use a different RNG such
85
86
// ' as the one from R.
86
- // ' @seealso The R documentation on its RNGs all of which are accessible via \pkg{Rcpp}.
87
+ // ' @seealso The R documentation on its RNGs all of which are accessible via \pkg{Rcpp}.
87
88
// [[Rcpp::export]]
88
89
void armadillo_set_seed (unsigned int val) {
89
90
// Rcpp::Rcout << "Setting value " << val << std::endl;
90
91
arma::arma_rng::set_seed (val); // set the seed to given value
91
- }
92
+ }
0 commit comments