Skip to content

Instantly share code, notes, and snippets.

robince /
Last active Oct 25, 2016 — forked from holgerdell/
Script to prepare arXiv package of a document that depends on texlive2015's version of biblatex (using pdflatex)
# This script is useful if:
# - you have a manuscript that you want to upload to the arXiv,
# - you are using biblatex, and
# - you are using texlive2015 while arXiv is still on texlive2011
# Put this file in a directory containing the manuscript you want to
# upload to, and adapt the paths below.
View extendarray.f90
module class_ExtendArray
implicit none
type, public :: ExtendArray
integer(8) :: capacity
integer(8) :: length
real(8), pointer :: data(:)
real(8), pointer :: buffer(:)
robince / isfoldernfs
Created Mar 13, 2015
isfoldernfs: script to check a destination directory is a nfs mount
View isfoldernfs
# check given path is an NFS mount
FSTYPE="$(df -P -T $1 | tail -n +2 | awk '{print $2}')"
# first three characters
if [ "$FSTYPE" = "nfs" ]
robince / rebin.m
Created Sep 12, 2013
rebin.m - Rebin an already discretised sequence (eg of intger values) into m levels
View rebin.m
function x = rebin(x_in,m)
% rebin(x, m) - rebin an integer sequence
% Rebin an already discretised sequence (eg of intger values) into m levels
x_flat = x_in(:);
% test for positive integer input
if any(mod(x_flat,1)) || (min(x_flat) < 0)
robince / fbin.f
Created Sep 12, 2013
fbin.f : Fast equally-populated bins using the quickselect algorithm
View fbin.f
module fbin
use iso_c_binding
implicit none
subroutine eqpop_bin(X, Nb, Ntrl, Xout)
integer, intent(in) :: Nb, Ntrl
real(c_double), intent(in) :: X(Ntrl)
integer(c_int8_t), intent(out) :: Xout(Ntrl)
robince / numbase2dec.m
Created Aug 11, 2013
numbase2dec.m : Optimised numerical base2dec
View numbase2dec.m
function d = numbase2dec(x,b)
%NUMBASE2DEC Convert base B numerical multivariate array to decimal integer.
% NUMBASE2DEC(x,B) converts the multivarate array of base B into its
% univariate decimal (base 10) equivalent.
% X should be M x Nt representing Nt different length-M base B words.
% Example
% numbase2dec([2; 1; 2],3) returns 23
robince / numdec2base.m
Created Aug 11, 2013
numdec2base.m: optimized numerical dec2base
View numdec2base.m
function x = numdec2base(d,b,m)
%NUMDEC2BASE Convert decimal univariate integer to base B multivariate vector.
% NUMDEC2BASE(D,B,M) returns the representation of D as a length-M base-B
% word.
% Examples
% numdec2base(23,3) returns [2;1;2]
% numdec2base(23,3,5) returns [0;0;2;1;2]
% See also NUMBASE2DEC
robince / savefaststruct.m
Created Jul 11, 2013
savefaststruct.m : savefast a structure (works inside parfor)
View savefaststruct.m
function savefaststruct(filename, savestruct)
% savefaststruct: fast saves of large arrays to .mat files
% Matlab's 'save' command can be very slow when saving large arrays,
% because by default Matlab attempts to use compression. This function
% provides a much faster alternative, at the cost of larger files.
% 'savefaststruct' version saves variables from a structure
% this avoids the need for evalin which does not work inside
% parfor etc.
robince / clonesharedmemory.m
Created Mar 13, 2013
clonesharedmemory.m : This function should be modified to load the required data and copy it to shared memory. It will be run once per physical machine.
View clonesharedmemory.m
function clonesharedmemory(shmkey)
% load your data here
x = rand(1000,1000);
sharedmatrix('clone', shmkey, x);
robince / setup_cluster_sharedmatrix.m
Last active Dec 14, 2015
View setup_cluster_sharedmatrix.m
% Start your pool!
% matlabpool open
% this cell gets details about the pool to find a single worker on
% each physical machine
% get all hosts and workers
t = getCurrentWorker();