我有一个包https://github.com/tfrostig/RSEE,其中包括一些(3)RcppArmadillo函数。该软件包在其他计算机上也可以正常工作。构建软件包时,不会出现任何错误,但是,每当我调用任何RCPP函数时,都会导致R崩溃。
当我尝试使用单元测试时,出现错误:“状态为-1073741819退出”。
如果我使用Rcpp::sourceCpp()
然后调用函数,则一切正常。具有Rcpp功能的其他软件包也可以正常工作。
例如:
`// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
// [[Rcpp::export]]
arma::mat localRegression(arma::mat weightmat, arma::mat modelmat, arma::vec xtemp) {
return inv(modelmat.t() * weightmat * modelmat) * modelmat.t() * weightmat * xtemp;
}
使用RSEE:::localRegression
会导致它崩溃。如果我使用加载源代码sourceCpp
,然后调用localRegression
它就可以了。
什么会导致这种类型的问题?
The session info is:
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Israel.1252 LC_CTYPE=English_Israel.1252 LC_MONETARY=English_Israel.1252
[4] LC_NUMERIC=C LC_TIME=English_Israel.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RSEE_0.1.0
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3 Rcpp_1.0.6
在你的包以一看,我假设的错误和崩溃源于 arma::mat iterLowess(..., double epsmed = 10^(-6)) {
在src/RCPP_LOWESS.cpp
。请注意,这^
不是Cpp中的幂运算,而是字节XOR
运算。此外,它10
是一个整数,而它10.0
是一个双精度数,因此尽管编译器“应”执行自动转换,但它可能只是失败。
尝试例如
library(Rcpp)
f <- cppFunction('double powww(double x = 10^(-6)){
double y = x^2;
return y;}')
您会注意到这会引发错误。
几乎不可能给您确切的答案,因为我们在问题中的信息非常有限,但是由于您提到它在调用函数时立即崩溃(我也假设它在调试状态下也会崩溃),因此我们应该查看错误的函数定义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句