Skip to content

Commit 4257515

Browse files
committed
do not trigger rand() use warning in skeleton (closes #69)
1 parent ca305c8 commit 4257515

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-03-29 Dirk Eddelbuettel <edd@debian.org>
2+
3+
* inst/skeleton/rcppeigen_hello_world.cpp: Rework first example to
4+
not rely on Eigen RNG which R CMD check would complain about.
5+
16
2019-02-16 James Joseph Balamuta <balamut2@illinois.edu>
27

38
* R/runit.RcppEigen.R: Removed listing RcppEigen in Imports during

inst/skeleton/rcppeigen_hello_world.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
// [[Rcpp::export]]
1818
Eigen::MatrixXd rcppeigen_hello_world() {
1919
Eigen::MatrixXd m1 = Eigen::MatrixXd::Identity(3, 3);
20-
Eigen::MatrixXd m2 = Eigen::MatrixXd::Random(3, 3);
21-
20+
// Eigen::MatrixXd m2 = Eigen::MatrixXd::Random(3, 3);
21+
// Do not use Random() here to not promote use of a non-R RNG
22+
Eigen::MatrixXd m2 = Eigen::MatrixXd::Zero(3, 3);
23+
for (auto i=0; i<m2.rows(); i++)
24+
for (auto j=0; j<m2.cols(); j++)
25+
m2(i,j) = R::rnorm(0, 1);
26+
2227
return m1 + 3 * (m1 + m2);
2328
}
2429

2530

26-
// another simple example: outer product of a vector,
31+
// another simple example: outer product of a vector,
2732
// returning a matrix
2833
//
2934
// [[Rcpp::export]]

0 commit comments

Comments
 (0)