Articles by Rcpp Gallery

Cleaner Generic Functions with RCPP_RETURN Macros

July 25, 2017 | Rcpp Gallery

TL;DR C++ templates and function overloading are incompatible with R’s C API, so polymorphism must be achieved via run-time dispatch, handled explicitly by the programmer. The traditional technique for operating on SEXP objects in a generic manner entails a great deal of boilerplate code, which can be unsightly, ... [Read more...]

Using Rcpp with C++11, C++14 and C++17

February 18, 2017 | Rcpp Gallery

Background When we started the Rcpp Gallery in late 2012, a few of us spent the next four weeks diligently writing articles ensuring that at least one new article would be posted per day. Two early articles covered the then-budding support for C++11. ... [Read more...]

Using Armadillo with SuperLU

February 17, 2017 | Rcpp Gallery

Armadillo is very versatile C++ library for linear algebra, brough to R via the RcppArmadillo package. It has proven to be very useful and popular, and is (as of February 2017) used by well over 300 CRAN packages as indicated by the reverse depends / ... [Read more...]

RcppHoney Introduction

July 25, 2016 | Rcpp Gallery

Rationale In C++ we often have containers that are not compatible with R or Rcpp with data already in them (std::vector, std::set, etc.). One would like to be able to operate on these containers without having to copy them into Rcpp structures like I...
[Read more...]

Rcpp::algorithm

June 24, 2016 | Rcpp Gallery

Introduction A while back I saw a post on StackOverflow where the user was trying to use Rcpp::sugar::sum() on an RcppParallel::RVector. Obviously this doesn’t work and it raised the question “Why doesn’t something more generic exist to provide functions with R semantics that can be ...
[Read more...]

Working with Rcpp::StringVector

June 22, 2016 | Rcpp Gallery

Vectors are fundamental containers in R. This makes them equally important in Rcpp. Vectors can be useful for storing multiple elements of a common class (e.g., integer, numeric, character). In Rcpp, vectors come in the form of NumericVector, CharacterVector, LogicalVector, StringVector and more. Look in the header file Rcpp/...
[Read more...]

Optimizing Code vs Recognizing Patterns with 3D Arrays

June 7, 2016 | Rcpp Gallery

Intro As is the case with the majority of posts normally born into existence, there was an interesting problem that arose on recently on StackOverflow. Steffen, a scientist at an unnamed weather service, faced an issue with the amount of computational time required by his triple loop in R. Specifically, ...
[Read more...]

Hierarchical Risk Parity Implementation in Rcpp and OpenMP

May 26, 2016 | Rcpp Gallery

Summary Recent research by Marcos Lopez de Prado aims to improve Markowitz’s Critical Line Algorithm (CLA). The (currently patent-pending) methodology proposes the Hierarchical Risk Parity (HRP) approach which aims to tackle several issues with the original CLA: instability, concentration, and underperformance. HRP applies modern mathematics (graph theory and machine ... [Read more...]

Gerber Statistic Implementation in Rcpp and OpenMP

May 25, 2016 | Rcpp Gallery

Summary Recently new research has appeared on using a co-movement measure to construct the covariance matrix as part of the Modern Portfolio Theory (MPT) style portfolio construction. Below is the abstract of the Gerber, Markowith and Pujara (2015) paper whose methodology is also currently patent pending: Markowitz’s mean-variance MPT has ... [Read more...]

SIMD Map-Reduction with RcppNT2

February 1, 2016 | Rcpp Gallery

Introduction The Numerical Template Toolbox (NT2) collection of header-only C++ libraries that make it possible to explicitly request the use of SIMD instructions when possible, while falling back to regular scalar operations when not. NT2 itself is powered by Boost, alongside two proposed Boost libraries – Boost.Dispatch, which provides a ...
[Read more...]

Using RcppNT2 to Compute the Variance

January 31, 2016 | Rcpp Gallery

Introduction The Numerical Template Toolbox (NT2) collection of header-only C++ libraries that make it possible to explicitly request the use of SIMD instructions when possible, while falling back to regular scalar operations when not. NT2 itself is p... [Read more...]

Introduction to RcppNT2

January 31, 2016 | Rcpp Gallery

Modern CPU processors are built with new, extended instruction sets that optimize for certain operations. A class of these allow for vectorized operations, called Single Instruction / Multiple Data (SIMD) instructions. Although modern compilers will u... [Read more...]

Introduction to RcppNT2

January 31, 2016 | Rcpp Gallery

Modern CPU processors are built with new, extended instruction sets that optimize for certain operations. A class of these allow for vectorized operations, called Single Instruction / Multiple Data (SIMD) instructions. Although modern compilers will use these instructions when possible, they are often unable to reason about whether or not a ...
[Read more...]

Using RcppNT2 to Compute the Variance

January 31, 2016 | Rcpp Gallery

Introduction The Numerical Template Toolbox (NT2) collection of header-only C++ libraries that make it possible to explicitly request the use of SIMD instructions when possible, while falling back to regular scalar operations when not. NT2 itself is powered by Boost, alongside two proposed Boost libraries – Boost.Dispatch, which provides a ...
[Read more...]

Using RcppNT2 to Compute the Sum

January 31, 2016 | Rcpp Gallery

Introduction The Numerical Template Toolbox (NT2) collection of header-only C++ libraries that make it possible to explicitly request the use of SIMD instructions when possible, while falling back to regular scalar operations when not. NT2 itself is powered by Boost, alongside two proposed Boost libraries – Boost.Dispatch, which provides a ...
[Read more...]

Writing fast asynchronous SGD/AdaGrad with RcppParallel

January 23, 2016 | Rcpp Gallery

Word embeddings After Tomas Mikolov et al. released word2vec tool, there was a boom of articles about words vector representations. One of the greatest is GloVe, which did a big thing by explaining how such algorithms work. It also refolmulates word2vec optimization as a special kind of factoriazation ...
[Read more...]

Serialize and Deserialize a C++ Object in Rcpp

November 6, 2015 | Rcpp Gallery

This post shows how to serialize a c++ object to the raw vector in R and deserialize it with the help of Rcereal and BH. First, please install the Rcpp, Rcereal, and BH from CRAN and enable the support of C++11 via Sys.setenv("PKG_CXXFLAGS"="-std=c++11"). We can ...
[Read more...]
1 2 3 4 6

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)