The C code is copyright Tristen Hayfield and Jeffrey S. Racine except where noted, the R port copyright Tristen Hayfield and Jeffrey S. Racine.