Skip to content

Commit

Permalink
Registering native routines for R 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
andrechalom committed Jun 11, 2017
1 parent efe7915 commit 231adc8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: pse
Type: Package
Title: Parameter Space Exploration with Latin Hypercubes
Version: 0.4.6
Date: 2016-07-19
Version: 0.4.7
Date: 2017-06-11
Author: Andre Chalom, Paulo Inacio Knegt Lopez de Prado
Maintainer: Andre Chalom <[email protected]>
Depends:
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export(tell)
import(Hmisc)
import(graphics)
import(stats)
useDynLib(pse, corcorr)
useDynLib(pse, .registration = "TRUE", .fixes = "C_")
4 changes: 2 additions & 2 deletions R/LHScorcorr.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' \emph{arXiv}:1210.6278 [q-bio.QM]
#' @export
#' @import stats
#' @useDynLib pse, corcorr
#' @useDynLib pse, .registration = "TRUE", .fixes = "C_"
LHScorcorr <-
function (vars, COR = 0, method=c("Pearson", "Spearman"), eps = 0.005, echo=FALSE, maxIt = 0) {
method <- match.arg(method)
Expand Down Expand Up @@ -76,7 +76,7 @@ internal.LHScorcorr <- function (vars, COR, l, eps, it, echo, maxIt) {
}
if (echo==T) cat(paste("Info: Correlation correction being made for l =",l,"/",M, "\n"))
# Here we start correcting the correlation for var[,l]
V <- .C(corcorr, vars=as.double(as.matrix(vars)),cor=as.double(COR), N=as.integer(N), M=as.integer(M), l=as.integer(l), FLAGSTOP=as.integer(0))
V <- .C(C_corcorr, vars=as.double(as.matrix(vars)),cor=as.double(COR), N=as.integer(N), M=as.integer(M), l=as.integer(l), FLAGSTOP=as.integer(0))
vars <- as.data.frame(matrix(V$vars, nrow=N, ncol=M))
names(vars) <- my.names
if (V$FLAGSTOP == 1) { # Convergence, going for next
Expand Down
21 changes: 21 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdlib.h>
#include <R_ext/Rdynload.h>
#include <Rinternals.h>

void corcorr (double *vars, double *cor, int * N, int * M, int * l, int * FLAGSTOP);

/* Registering native routine for R 3.4.0 */
static R_NativePrimitiveArgType C_types[] = {
REALSXP, REALSXP, INTSXP, INTSXP, INTSXP, INTSXP
};

static const R_CMethodDef cMethods[] = {
{"corcorr", (DL_FUNC) &corcorr, 6, C_types},
{NULL, NULL, 0, NULL}
};

void R_init_pse(DllInfo *dll) {
R_registerRoutines(dll, cMethods, NULL, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
R_forceSymbols(dll, TRUE);
}

0 comments on commit 231adc8

Please sign in to comment.