Comments (12)
As I said at the outset, I do not consider myself here in the role of an editor or reviewer for Eigen code. If they include code that may trigger R warnings I officially do not care. I am here to support the basic use cases not involving
rand
.
Ok, fair enough. In that case the proposed change to rcppeigen_hello_world()
is sufficient.
from rcppeigen.
I am a little disappointed by this Ralf. You surely know that a non-included header is of no impact in a shared library, no?
And for what it is worth I do not consider myself to be in the business of policing / editing / patching tens of thousands of that many files. If you think the world needs a 'BHplus' please suggest it to CRAN.
from rcppeigen.
Maybe I am more dense than normal, but I do not understand why you are refering to a "non-included header" file. The above quoted file is included if one includes RcppEigen.h
. As it turns out, the default skeleton package using RcppEigen triggers the NOTE from R CMD check that rand()
should not be used:
$ R -e "RcppEigen::RcppEigen.package.skeleton('EigenRand')"
[...]
$ R CMD build EigenRand
[...]
$ R CMD check EigenRand_1.0.tar.gz
[...]
* checking compiled code ... NOTE
File ‘EigenRand/libs/EigenRand.so’:
Found ‘rand’, possibly from ‘rand’ (C)
Object: ‘rcppeigen_hello_world.o’
Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor use Fortran I/O
nor system RNGs.
See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.
* checking examples ... OK
* checking PDF version of manual ... OK
* DONE
Status: 1 NOTE
See
‘/tmp/EigenRand.Rcheck/00check.log’
for details.
$ nm -A -g -C EigenRand.Rcheck/00_pkg_src/EigenRand/src/*o | grep rand
EigenRand.Rcheck/00_pkg_src/EigenRand/src/EigenRand.so: U rand@@GLIBC_2.2.5
EigenRand.Rcheck/00_pkg_src/EigenRand/src/rcppeigen_hello_world.o: U rand
Probably due to this line:
One might argue that this case is pathologic. I am not sure, though, how the OP of that thread on r-pkg-devel managed to trigger that NOTE.
from rcppeigen.
Hm. Did anything change there? Lemme reopen then...
from rcppeigen.
Oh, I see now what you mean. That is a stupid example -- will change to calling R's RNG.
from rcppeigen.
From the top of your head, any other good initializers you'd recomment from here ? Maybe LinSpaced
?
from rcppeigen.
Draft:
Eigen::MatrixXd rcppeigen_hello_world() {
Eigen::MatrixXd m1 = Eigen::MatrixXd::Identity(3, 3);
//Eigen::MatrixXd m2 = Eigen::MatrixXd::Random(3, 3);
Eigen::MatrixXd m2 = Eigen::MatrixXd::Zero(3, 3);
for (auto i=0; i<m2.rows(); i++)
for (auto j=0; j<m2.cols(); j++)
m2(i,j) = R::rnorm(0, 1);
return m1 + 3 * (m1 + m2);
}
from rcppeigen.
That removes the NOTE for the default skeleton, but the fundamental problem remains. One can trigger Eigen into using std::rand()
even in less obvious ways than calling a method called Random
. For example, the following function also triggers the rand()
NOTE:
Eigen::MatrixXd rcppeigen_hello_world() {
Eigen::MatrixXd m1 = Eigen::MatrixXd::Identity(3, 3);
//Eigen::MatrixXd m2 = Eigen::MatrixXd::Random(3, 3);
Eigen::MatrixXd m2 = Eigen::MatrixXd::Zero(3, 3);
for (auto i=0; i<m2.rows(); i++)
for (auto j=0; j<m2.cols(); j++)
m2(i,j) = R::rnorm(0, 1);
Eigen::RealQZ<Eigen::MatrixXd> qz(3);
qz.compute(m1,m2);
return m1 + 3 * (m1 + m2);
}
since Eigen::RealQZ
uses internal::random()
(which in turn uses std::rand()
) in some corner cases:
RcppEigen/inst/include/Eigen/src/Eigenvalues/RealQZ.h
Lines 439 to 442 in 9abb401
from rcppeigen.
I am sorry. I do not understand what you're after here.
I believe we are both aware that Writing R Extensions and the R CMD check
tests dislike the C library RNG. Which is why we are rewriting it in ways to NOT trigger it.
As opposed to enumerating all possible ways to trigger it. So why would RealQZ()
help?
As I said at the outset, I do not consider myself here in the role of an editor or reviewer for Eigen code. If they include code that may trigger R warnings I officially do not care. I am here to support the basic use cases not involving rand
.
from rcppeigen.
I meanwhile think that the OP of that r-pkg-devel thread used the Random
method. In that case it might be sufficient to document some restrictions:
Don't use
Random()
orRealQZ
if you want to submit your package to CRAN.
from rcppeigen.
Yes. Writing R Extension does that. R CMD check checks for it. But I also do not do house visits to patch their system's C library.
from rcppeigen.
Good to have agreement. Shipping examples that trigger warnings and hence do not provide best practives is something I don't like so thanks for pointing me here. That had long been overlooked.
from rcppeigen.
Related Issues (20)
- Warning messages: 1: partial match of 'df' to 'df.residual' HOT 6
- Unable to install v0.3.3.9.3 (zero exis status, warning: ignoring attributes on template argument ‘__m128) HOT 4
- Can't install on arm64 (MacOS) HOT 1
- EIGEN_DEFAULT_TO_ROW_MAJOR and other flags HOT 3
- Runtime error causing R session to crash HOT 6
- Undefined symbol: RcppEigen_Eigen_SSE HOT 3
- Error while trying to create shinyproxy image HOT 1
- no member named 'Rlog1p' in namespace 'std' HOT 11
- (Rcpp)Eigen 3.4.0 would help with C++17 HOT 2
- Small DESCRIPTION issue HOT 1
- Why macros for GCC in DisableStupidWarnings.h are commented HOT 2
- Small inconsistency in the `lmBenchmark.R` file? HOT 4
- Lots of warnings During Compilation HOT 1
- Can not install RcppEigen, RcppEigen.h: No such file or directory HOT 7
- make fastLm use mutliple threads HOT 3
- Error installing RcppEigen HOT 4
- Map dgCmatrix as integer sparse matrix HOT 6
- RcppEigen Submatrix Views HOT 2
- setFromTriplets function gets segfault error HOT 5
- Installation issues in a conda environment HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rcppeigen.