我想禁用在RcppArmadillo中访问矩阵元素时的边界检查。
Armadillo文档说:
“可以通过编辑文件include/armadillo_bits/config.hpp来配置Armadillo。可以通过取消或注释掉特定的#define来启用或禁用特定功能,如下所示。”
但在R包的上下文中,我该如何激活这个指令?
我尝试创建了一个config.h文件,其中包含:
Armadillo文档说:
“可以通过编辑文件include/armadillo_bits/config.hpp来配置Armadillo。可以通过取消或注释掉特定的#define来启用或禁用特定功能,如下所示。”
但在R包的上下文中,我该如何激活这个指令?
我尝试创建了一个config.h文件,其中包含:
#ifndef CONFIG_LOADED
#define CONFIG_LOADED
#define ARMA_NO_DEBUG
#endif
然后将其包含在我的/src
文件夹中的每个.cpp文件中,但我不确定它是否正常工作,或者是否有其他方法而不是在每个.cpp文件中添加#include "config.h"
。
目前我有一个.cpp文件(包含主要算法),它以以下方式开始:
#include "configs.h"
#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
// [[Rcpp::export]]
SEXP sample_gibbs_cpp(const arma::vec& v_n, const arma::mat& W,
arma::vec h_n, double alpha = 1, double beta = 1, int iter=100,
double burnin = 0.5){
... code ...
}
还有一些其他的内容是关于IT技术的。
#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
... code ...
我的DESCRIPTION文件:
Package: mypackage
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("First", "Last", email = "first.last@example.com", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends:
R (>= 3.2.3)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 5.0.1
Imports:
ggplot2,
dplyr,
tidyr,
rstan
LinkingTo: Rcpp, RcppArmadillo, RcppEigen
SystemRequirements: C++11
我使用以下方式编译我的软件包:
devtools::load_all()