我有一个C ++函数,当源独立地使用RCPP R中的作品,但是当我包括它在一个编译ř包,我继续接收以下错误:error: arma::memory::acquire(): out of memory。在这篇文章中,我提供了包含Znew_gen2要在我编译的 R 包中使用的函数的 C++ 代码。使用一个工作示例,我可以证明该Znew_gen2函数在我独立获取它时(在 R 包之外)有效。但是,当我从名为 的示例 R 包中调用相同的函数时HelpWithZnewgen2,该函数不再起作用,并且出现错误error: arma::memory::acquire(): out of memory。本文中提到的所有代码都可以在 GitHub 存储库https://github.com/hheiling/myrepo_R 中找到。
我的工作示例在此处提供:
# Working Example:
library(bigmemory)
library(Matrix)
set.seed(1)
U = matrix(rnorm(3000), nrow=100, ncol=30)
Z = matrix(rnorm(15000), nrow = 500, ncol = 30)
group = rep(1:10, each = 50)
cols = c(1,11,21)
n = 500
q = 3
d = 10
Znew = big.matrix(nrow = nrow(Z)*nrow(U), ncol …Run Code Online (Sandbox Code Playgroud)