From 208f3c8b9c50a1f3802362edd07bb054e43dd138 Mon Sep 17 00:00:00 2001 From: vwmaus Date: Mon, 20 Mar 2017 15:21:00 +0100 Subject: [PATCH] Include call to R_registerRoutines. CRAN NOTE not solved yet. --- NAMESPACE | 1 - R/twdtw.R | 2 +- R/zzz.R | 2 +- src/dtwSat-init.c | 26 ++++++++++++++++++++++++++ src/f.h | 13 +++++++++++++ 5 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/dtwSat-init.c create mode 100644 src/f.h diff --git a/NAMESPACE b/NAMESPACE index 6eced6b..d0f0416 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -116,7 +116,6 @@ importFrom(stats,window) importFrom(stats,xtabs) importFrom(xtable,print.xtable) importFrom(xtable,xtable) -useDynLib(dtwSat, .registration = TRUE) useDynLib(dtwSat,bestmatches) useDynLib(dtwSat,computecost) useDynLib(dtwSat,g) diff --git a/R/twdtw.R b/R/twdtw.R index bf3ef45..154a0cb 100644 --- a/R/twdtw.R +++ b/R/twdtw.R @@ -147,7 +147,7 @@ initAlignments = function(...){ #' @useDynLib dtwSat g .g = function(phi, step.matrix){ - if(!is.loaded("computecost", PACKAGE = "dtwSat", type = "Fortran")) + if(!is.loaded("g", PACKAGE = "dtwSat", type = "Fortran")) stop("Fortran lib is not loaded") n = nrow(phi) diff --git a/R/zzz.R b/R/zzz.R index 7c1b731..26e7ed9 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -35,7 +35,7 @@ #' @importFrom lubridate month month<- day day<- year year<- #' @importFrom caret createDataPartition #' @importFrom xtable xtable print.xtable -#' @useDynLib dtwSat, .registration = TRUE +# @useDynLib dtwSat, .registration = TRUE #' NULL diff --git a/src/dtwSat-init.c b/src/dtwSat-init.c new file mode 100644 index 0000000..ffb999e --- /dev/null +++ b/src/dtwSat-init.c @@ -0,0 +1,26 @@ +// RegisteringDynamic Symbols + +#include +#include +#include +#include +#include "f.h" + +static R_FortranMethodDef fortranMethods[] = { + {"bestmatches", (DL_FUNC) &F77_SUB(bestmatches), 11}, + {"computecost", (DL_FUNC) &F77_SUB(computecost), 7}, + {"g", (DL_FUNC) &F77_SUB(g), 4}, + {"tracepath", (DL_FUNC) &F77_SUB(tracepath), 11}, + {NULL, NULL, 0} +}; + +void +#ifdef HAVE_VISIBILITY_ATTRIBUTE + __attribute__ ((visibility ("default"))) +#endif +R_init_dtwSat(DllInfo *dll) { + R_registerRoutines(dll, NULL, NULL, fortranMethods, NULL); + R_useDynamicSymbols(dll, FALSE); +} + + diff --git a/src/f.h b/src/f.h new file mode 100644 index 0000000..9174a57 --- /dev/null +++ b/src/f.h @@ -0,0 +1,13 @@ + +void F77_SUB(computecost) +(double *CM, int *DM, int *VM, int *SM, int *N, int *M, int *NS); + +void F77_SUB(bestmatches) +(int *XM, double *AM, double *DM, int *DP, int *X, int *IM, int *A, int *K, int *P, int *L, double *OV); + +void F77_SUB(g) +(double *TM, int *N, int *M, double *PC); + +void F77_SUB(tracepath) +(double *DM, double *SM, double *JMIN, double *IND1, double *IND2, double *POS, int *N, int *M, int *NS, int *NJ, int *AL); +