Skip to content

Instantly share code, notes, and snippets.

View hdarjus's full-sized avatar
👋

Darjus Hosszejni hdarjus

👋
  • Personal Account
  • Vienna
View GitHub Profile
@hdarjus
hdarjus / Debug-Cpp-within-R.md
Last active September 27, 2021 13:32
Debug C++ in an R package

Description

Feel free to share the content but please refer back to this original post whenever possible. Thanks, I appreciate it. The code comes without warranty and no responsibility is taken. There may be typos.

Setup

Here I document my setup for debugging the C++ code of any R package. This collection of files assumes that the stochvol package is debugged. This should work with C code as well, and it does not matter whether the package uses Rcpp. The setup uses GDB. Most importantly, the package has to be compiled with debug information and ideally with all optimizations turned off.

@hdarjus
hdarjus / load-Nelson-Plosser.R
Last active September 16, 2021 08:19
Data Loader for the Nelson-Plosser US Macroeconomic Time Series
library("tseries")
data("NelPlo")
View(NelPlo)
@hdarjus
hdarjus / Rcpp_vs_RcppArmadillo.R
Last active June 12, 2019 15:30
A quick speed test to tell the difference between using Rcpp objects and using RcppArmadillo objects. All the functions do essentially the same, they return their input, so if there is speed difference then it's due to extra memory allocations, a.k.a. unnecessary copying.
library(Rcpp)
library(microbenchmark)
cppFunction("
NumericVector rcpp2rcpp(const NumericVector& x) {
return x;
}",
depends="RcppArmadillo",
plugins="cpp11")
cppFunction("
@hdarjus
hdarjus / !Config files
Last active March 25, 2019 08:05
Config files
From various online sources. I show the original source where I still remember, and I don't own the code here.
@hdarjus
hdarjus / !Worth knowing
Last active March 25, 2019 08:08
Blogs I should read
Blogs, software packages, etc. I don't list really well known things here :)