Skip to content

Instantly share code, notes, and snippets.

View stephenjbarr's full-sized avatar

Stephen Jeffrey Barr stephenjbarr

View GitHub Profile
@stephenjbarr
stephenjbarr / sjb_rinside1.cpp
Created August 30, 2012 05:36
an example of using R's optim to optimize a C++ function exposed via Rcpp::InternalFunction
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// Simple example showing how expose a C++ function
//
// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
#include <RInside.h> // for the embedded R via RInside
// a c++ function we wish to expose to R
const char* hello( std::string who ){
@stephenjbarr
stephenjbarr / sjb_mpi.cc
Created August 30, 2012 04:17
why does the MPI section fail
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// SJB - first shot at RInside and Eigen combined
//
// Copyright (C) 2012 Stephen J. Barr
//
// GPL'ed
#include <iostream>
@stephenjbarr
stephenjbarr / sjb_nll_optim.cc
Created August 30, 2012 02:13
attempt at MPI optimizaer
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// SJB - first shot at RInside and Eigen combined
//
// Copyright (C) 2012 Stephen J. Barr
//
// GPL'ed
#include <iostream>
@stephenjbarr
stephenjbarr / test.R
Created April 6, 2012 17:43
Here is my trended R code to plot trended vs detrended data
## Stephen J. Barr
## - this is some practice retrending the model
setwd("/home/stevejb/myhg/is-solver/indep_sim/")
retrendDemo <- function(THETA = 0.7880) {
## produce initial values
x = rnorm(30, sd=.03)
@stephenjbarr
stephenjbarr / sjb-subsettest.cpp
Created April 5, 2012 16:14
playing with subsetting in Eigen
#include <iostream>
#include <iomanip>
#include <fstream>
#include "mkl.h"
#include "math.h"
#include <vector>
#include <cmath>
#include <string>
@stephenjbarr
stephenjbarr / rgen_eigen.cpp
Created April 3, 2012 04:35
lightning fast matrices of random numbers with Eigen and Tina's Random Number Generator
// AUTHOR: Stephen J. Barr
#include <trng/config.hpp>
#if defined TRNG_HAVE_OPENMP
#include <cstdlib>
#include <iostream>
#include <omp.h>
#include <trng/yarn2.hpp>
#include <trng/uniform01_dist.hpp>
@stephenjbarr
stephenjbarr / test_csv_parse.cpp
Created March 31, 2012 17:22
using boost tokenizer to parse CSV files into Eigen Matrices
#include <iostream>
#include <iomanip>
#include <fstream>
#include "mkl.h"
#include "math.h"
#include <vector>
#include <cmath>
#include <string>
#include <cstdlib>