[英]What is the random number generator that Armadillo uses?
我正在使用R Armadillo C ++庫中的隨機數生成器.Armadillo允許對矩陣和向量進行高性能計算。 但是,我無法看到它實際實現的是哪個隨機數生成器。
Rcpp Armadillo使用的隨機數生成器究竟是什么?
根據RcppArmadillo是針對C ++ 98標准(當前是默認值)還是針對C ++ 11(可選)進行編譯,可以使用兩種不同的RNG。 [...]對於C ++ 98,使用系統庫RNG。 它可能性能較差,尤其是在舊版本的Windows上。 對於C ++ 11,使用其庫中包含的RNG。 - RcppArmadillo文檔
“對於C ++ 98,使用了系統庫RNG。” - 系統庫RNG是std::rand()
,雖然看起來好像RcppArmadillo使用來自R的RNG作為后備(當沒有選擇C ++ 11以便基於C ++ 11的RNG不可用時),這避免了使用舊的基於C ++ 98的std::rand()
。 1
“對於C ++ 11,使用其庫中包含的RNG。” - 這是指C ++ 11 <random>
庫。
另一方面,也請在RcppArmadilloForward.h中考慮這個評論 :
// using this define makes the R RNG have precedent over both the
// C++11-based RNG provided by Armadillo, as well as the C++98-based
// fallback.
//
// One can use the C++11-based on by commenting out the following
// #define and also selecting C++11 (eg via src/Makevars* or the
// DESCRIPTION file) and/or defining #define-ing ARMA_USE_CXX11_RNG
#define ARMA_RNG_ALT RcppArmadillo/Alt_R_RNG.h
它將R RNG作為RcppArmadillo的引擎。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.