This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <utility> | |
#include <algorithm> | |
#include <boost/ref.hpp> | |
#include <boost/type_traits/remove_reference.hpp> | |
#include <boost/iterator/iterator_facade.hpp> | |
#include <boost/range/iterator_range.hpp> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <boost/iterator/iterator_categories.hpp> | |
#include <boost/iterator/transform_iterator.hpp> | |
#include <boost/range/adaptor/transformed.hpp> | |
#include <boost/range/any_range.hpp> | |
#include <boost/range/numeric.hpp> | |
#include <boost/timer/timer.hpp> | |
#include <iostream> | |
#include <fstream> | |
#include <vector> | |
#include <numeric> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setwd("c:/dir/containing/compiled/binary") | |
dyn.load("deep_thought") | |
.External('the_meaning_of_life', environment()) | |
.External('the_meaning_of_multiple_lives', 42, environment()) | |
dyn.unload("deep_thought") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(data.table) | |
nl <- 100 | |
stp <- 50000 | |
ss <- stp | |
ss <- seq(stp, length.out=20, by=stp) | |
times <- sapply(ss, function(ss) { | |
mydata <- data.frame( | |
to_location_id = as.factor(sample(nl, ss, T)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <utility> | |
#include <iterator> | |
#include <R.h> | |
#include <Rdefines.h> | |
template<typename Iter> | |
SEXP makePolygon(Iter b, Iter e) { | |
SEXP | |
coords; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A 'functor descriptor' that can be used to generate a runtime polymorphic functor | |
* for a set of input/ouput types. To be used to create python extensions in C++ for | |
* wrapping with boost::python, such that the functors can be configured in Python | |
* then applied to a number (greater than 1) of non-polymorphic input/output types | |
* in C++ (the types used in practice will not be those in first_types and second | |
* types, which are just for convenience). | |
*/ | |
#include <new> // placement new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pre <- scan() | |
51.11 | |
64.44 | |
73.33 | |
77.78 | |
66.67 | |
84.44 | |
68.89 | |
57.78 | |
64.44 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A wrapper around Rcartogram::cartogram for shape files. | |
# | |
# @param polys: Either a SpatialPolygonsDataFrame or the path to a shape file. | |
# @param variable: Either a string giving the name of the variable to used in polys@data, or a vector | |
# of the same length as polys@polygons. | |
# @param nx: The number of columns in the raster used to represent the region. | |
# @param ny: The number of rows in the raster used to represent the region. | |
# @param buffer.by: The proportion width of the buffer to add to the region (see ?Rcartogram::addBoundary). | |
# | |
# @return The new boundaries as A SpatialPolygonsDataFrame with the attribute 'cartogram.scaling.var'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test.func <- function(n.samples) { | |
nms <- c("Wichmann-Hill", "Marsaglia-Multicarry", "Super-Duper", "Mersenne-Twister", "Knuth-TAOCP-2002", "Knuth-TAOCP", "L'Ecuyer-CMRG") | |
tmp <- lapply(nms, function(unif.rng.name) { | |
RNGkind(unif.rng.name) | |
nms <- c("Kinderman-Ramage", "Ahrens-Dieter", "Box-Muller", "Inversion") | |
tmp <- sapply(nms, function(norm.rng.name) { | |
RNGkind(, norm.rng.name) | |
system.time(rnorm(n.samples)) | |
})[1:3,] | |
# included here because I'm not sure if rziggurat uses the unif rng internally. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copyright (C) 2006 Anthony M. Pasqualoni | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of the GNU General Public License | |
as published by the Free Software Foundation; either version 2 | |
of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
OlderNewer