本文整理汇总了C++中rcpp::IntegerVector::at方法的典型用法代码示例。如果您正苦于以下问题:C++ IntegerVector::at方法的具体用法?C++ IntegerVector::at怎么用?C++ IntegerVector::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcpp::IntegerVector
的用法示例。
在下文中一共展示了IntegerVector::at方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tabulate_cpp
// [[Rcpp::export]]
Rcpp::IntegerVector tabulate_cpp(const Rcpp::IntegerVector & v, R_xlen_t nlevels) {
// Using R_xlen_t to avoid checking for entries < 0
std::vector<R_xlen_t> table(nlevels);
R_xlen_t n = v.size();
for (R_xlen_t i = 0; i < n; ++i) {
table.at( v.at(i) - 1 ) ++;
}
// Wrapp may throw errors with R_xlen_t
// return wrap(table);
IntegerVector a(table.size());
std::copy(table.begin(), table.end(), a.begin());
return a;
}
示例2: magick_image_readbin
// [[Rcpp::export]]
XPtrImage magick_image_readbin(Rcpp::RawVector x, Rcpp::CharacterVector density, Rcpp::IntegerVector depth, bool strip = false){
XPtrImage image = create();
#if MagickLibVersion >= 0x689
Magick::ReadOptions opts = Magick::ReadOptions();
#if MagickLibVersion >= 0x690
opts.quiet(1);
#endif
if(density.size())
opts.density(std::string(density.at(0)).c_str());
if(depth.size())
opts.depth(depth.at(0));
Magick::readImages(image.get(), Magick::Blob(x.begin(), x.length()), opts);
#else
Magick::readImages(image.get(), Magick::Blob(x.begin(), x.length()));
#endif
if(strip)
for_each (image->begin(), image->end(), Magick::stripImage());
return image;
}
示例3: magick_image_readpath
// [[Rcpp::export]]
XPtrImage magick_image_readpath(Rcpp::CharacterVector paths, Rcpp::CharacterVector density, Rcpp::IntegerVector depth, bool strip = false){
XPtrImage image = create();
#if MagickLibVersion >= 0x689
Magick::ReadOptions opts = Magick::ReadOptions();
#if MagickLibVersion >= 0x690
opts.quiet(1);
#endif
if(density.size())
opts.density(std::string(density.at(0)).c_str());
if(depth.size())
opts.depth(depth.at(0));
for(int i = 0; i < paths.size(); i++)
Magick::readImages(image.get(), std::string(paths[i]), opts);
#else
for(int i = 0; i < paths.size(); i++)
Magick::readImages(image.get(), std::string(paths[i]));
#endif
if(strip)
for_each (image->begin(), image->end(), Magick::stripImage());
return image;
}