【发布时间】:2018-02-02 17:29:37
【问题描述】:
我想在访问 RcppArmadillo 中的矩阵元素时禁用边界检查。
犰狳的文献说
可以通过编辑文件来配置犰狳 包括/armadillo_bits/config.hpp。具体功能可以 通过取消注释或注释掉特定的启用或禁用 #define,如下所列。
但是在 R 包的上下文中,我怎样才能激活这个指令呢?
我尝试使用
创建一个config.h 文件
#ifndef CONFIG_LOADED
#define CONFIG_LOADED
#define ARMA_NO_DEBUG
#endif
然后将其包含在我的/src 文件夹的每个 .cpp 文件中,但我不确定它是否正常工作,或者除了添加#include "config.h" 之外是否还有其他方法在每个 .cpp 文件中。
目前我有一个 .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 ...
}
然后其他的只是
#include <RcppArmadillo.h>
using namespace Rcpp;
using namespace arma;
... code ...
我的描述文件:
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()
【问题讨论】:
-
包裹的邮政编码...特别是,您如何以及何时调用此标头?订单很重要。