Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
schw4b committed Mar 24, 2017
2 parents c95ee07 + bd1c0c3 commit ac54c2a
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: multdyn
Version: 1.5
Version: 1.5.1
Date: 2017-03-21
Title: Multiregression Dynamic Models
Author: Simon Schwab <schw4b@gmail.com>, Ruth Harbord <r.harbord@warwick.ac.uk>,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
useDynLib(multdyn)
useDynLib(multdyn, .registration = TRUE)
# Generated by roxygen2: do not edit by hand

export(binom.nettest)
Expand Down
56 changes: 52 additions & 4 deletions devel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

### Switch to develop branch
git checkout develop

### Review, pull, commit and push
git status
git diff
Expand All @@ -28,7 +28,7 @@
git pull # to update the state to the latest remote master state
git merge develop # to bring changes to local master from your develop branch
git push origin master # push current HEAD to remote master branch

## Package building for CRAN
make doc
make build
Expand All @@ -47,7 +47,7 @@ Test functions are written for the *testthat* package and can be found in the fo
OK: 22 SKIPPED: 0 FAILED: 0

DONE =========================================================================================

## Run benchmarks

library(devtools)
Expand All @@ -71,4 +71,52 @@ Test functions are written for the *testthat* package and can be found in the fo

60-fold speed improvement compared to the native R implementation (cpp=F).


## Magic stuff to resolve CRAN complaints

See https://github.com/RcppCore/Rcpp/issues/636

Download R-devel.tar.gz from https://cran.r-project.org/sources.html
```
mkdir ~/tmp
cd ~/tmp
wget https://stat.ethz.ch/R/daily/R-devel.tar.gz
tar -xvf R-devel.tar.gz
```
Then, in R, do the following:
```
source("~/tmp/R-devel/src/library/tools/R/sotools.R")
source("~/tmp/R-devel/src/library/tools/R/utils.R")
setwd("~/workspace/multdyn")
package_native_routine_registration_skeleton(".")
```
The function will output some code, copy and paste this to `src/register.c`
```
#include <R.h>
#include <Rinternals.h>
#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>
/* FIXME:
Check these declarations against the C/Fortran source code.
*/
/* .Call calls */
extern SEXP multdyn_dlmLplCpp(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
static const R_CallMethodDef CallEntries[] = {
{"multdyn_dlmLplCpp", (DL_FUNC) &multdyn_dlmLplCpp, 7},
{NULL, NULL, 0}
};
void R_init_multdyn(DllInfo *dll)
{
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
```

Finally, this needs to go into `NAMESPACE`, see Makefile.
```
useDynLib(packagename, .registration = TRUE).
```
22 changes: 22 additions & 0 deletions src/register.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <R.h>
#include <Rinternals.h>
#include <stdlib.h> // for NULL
#include <R_ext/Rdynload.h>

/* FIXME:
Check these declarations against the C/Fortran source code.
*/

/* .Call calls */
extern SEXP multdyn_dlmLplCpp(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);

static const R_CallMethodDef CallEntries[] = {
{"multdyn_dlmLplCpp", (DL_FUNC) &multdyn_dlmLplCpp, 7},
{NULL, NULL, 0}
};

void R_init_multdyn(DllInfo *dll)
{
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}

0 comments on commit ac54c2a

Please sign in to comment.