Commit 898b53f2 authored by Philip Rinn's avatar Philip Rinn
Browse files

Add package registration code

parent 7045f8cc
2017-07-20 Philip Rinn <philip.rinn@uni-oldenburg.de>
* Add package registration code
2016-08-29 Philip Rinn <philip.rinn@uni-oldenburg.de>
* Tag as version 1.2
* Update vignette to meet the published version of the paper
......
......@@ -20,4 +20,4 @@ Depends:
Imports:
Rcpp (>= 0.11.0)
LinkingTo: Rcpp, RcppArmadillo (>= 0.4.600.0)
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
......@@ -14,4 +14,4 @@ importFrom(stats,frequency)
importFrom(stats,is.mts)
importFrom(stats,is.ts)
importFrom(stats,median)
useDynLib(Langevin)
useDynLib(Langevin, .registration=TRUE)
......@@ -73,11 +73,10 @@
#' abline(h=1, col='red');
#' @import Rcpp
#' @importFrom stats frequency is.ts
#' @useDynLib Langevin
#' @useDynLib Langevin, .registration=TRUE
#' @export
Langevin1D <- function(data, bins, steps,
sf=ifelse(is.ts(data), frequency(data), 1), bin_min=100,
reqThreads=-1) {
.Call('Langevin_Langevin1D', PACKAGE='Langevin', data, bins, steps, sf,
bin_min, reqThreads)
.Call('_Langevin_Langevin1D', data, bins, steps, sf, bin_min, reqThreads)
}
......@@ -57,13 +57,12 @@
#' @seealso \code{\link{Langevin1D}}
#' @import Rcpp
#' @importFrom stats frequency is.mts
#' @useDynLib Langevin
#' @useDynLib Langevin, .registration=TRUE
#' @export
Langevin2D <- function(data, bins, steps,
sf=ifelse(is.mts(data), frequency(data), 1), bin_min=100,
reqThreads=-1) {
if(nrow(data) == 2)
stop("Time series have to be arranged in colums now. Please adopt your code!")
.Call('Langevin_Langevin2D', PACKAGE='Langevin', data, bins, steps, sf,
bin_min, reqThreads)
.Call('_Langevin_Langevin2D', data, bins, steps, sf, bin_min, reqThreads)
}
# This file was generated by Rcpp::compileAttributes
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
.Langevin1D <- function(data, bins, steps, sf, bin_min, reqThreads) {
.Call('Langevin_Langevin1D', PACKAGE = 'Langevin', data, bins, steps, sf, bin_min, reqThreads)
.Call(`_Langevin_Langevin1D`, data, bins, steps, sf, bin_min, reqThreads)
}
.Langevin2D <- function(data, bins, steps, sf, bin_min, reqThreads) {
.Call('Langevin_Langevin2D', PACKAGE = 'Langevin', data, bins, steps, sf, bin_min, reqThreads)
.Call(`_Langevin_Langevin2D`, data, bins, steps, sf, bin_min, reqThreads)
}
.timeseries1D <- function(N, startpoint, d13, d12, d11, d10, d22, d21, d20, sf, dt) {
.Call('Langevin_timeseries1D', PACKAGE = 'Langevin', N, startpoint, d13, d12, d11, d10, d22, d21, d20, sf, dt)
.Call(`_Langevin_timeseries1D`, N, startpoint, d13, d12, d11, d10, d22, d21, d20, sf, dt)
}
.timeseries2D <- function(N, startpointx, startpointy, D1_1, D1_2, g_11, g_12, g_21, g_22, sf, dt) {
.Call('Langevin_timeseries2D', PACKAGE = 'Langevin', N, startpointx, startpointy, D1_1, D1_2, g_11, g_12, g_21, g_22, sf, dt)
.Call(`_Langevin_timeseries2D`, N, startpointx, startpointy, D1_1, D1_2, g_11, g_12, g_21, g_22, sf, dt)
}
......@@ -25,10 +25,10 @@
#' t <- 1:1e4;
#' plot(t, s, t="l", main=paste("mean:", mean(s), " var:", var(s)));
#' @import Rcpp
#' @useDynLib Langevin
#' @useDynLib Langevin, .registration=TRUE
#' @export
timeseries1D <- function(N, startpoint = 0, d13 = 0, d12 = 0, d11 = -1, d10 = 0,
d22 = 0, d21 = 0, d20 = 1, sf = 1000, dt = 0) {
.Call('Langevin_timeseries1D', PACKAGE = 'Langevin', N, startpoint, d13,
d12, d11, d10, d22, d21, d20, sf, dt)
.Call('_Langevin_timeseries1D', N, startpoint, d13, d12, d11, d10, d22,
d21, d20, sf, dt)
}
......@@ -50,7 +50,7 @@
#' @author Philip Rinn
#' @seealso \code{\link{timeseries1D}}
#' @import Rcpp
#' @useDynLib Langevin
#' @useDynLib Langevin, .registration=TRUE
#' @export
timeseries2D <- function(N, startpointx=0, startpointy=0,
D1_1=matrix(c(0,-1,rep(0,14)),nrow=4),
......@@ -60,6 +60,6 @@ timeseries2D <- function(N, startpointx=0, startpointy=0,
g_21=matrix(c(0,0,0,0,0,0,0,0,0),nrow=3),
g_22=matrix(c(1,0,0,0,0,0,0,0,0),nrow=3),
sf=1000, dt=0) {
.Call('Langevin_timeseries2D', PACKAGE = 'Langevin', N, startpointx,
startpointy, D1_1, D1_2, g_11, g_12, g_21, g_22, sf, dt)
.Call('_Langevin_timeseries2D', N, startpointx, startpointy, D1_1, D1_2,
g_11, g_12, g_21, g_22, sf, dt)
}
### Langevin Analysis in One and Two Dimensions
The [Langevin package](http://cran.r-project.org/package=Langevin) provides R
The [Langevin package](https://cran.r-project.org/package=Langevin) provides R
functions to estimate drift and diffusion functions from time series and
generate synthetic time series from given drift and diffusion coefficients.
......@@ -9,7 +9,7 @@ generate synthetic time series from given drift and diffusion coefficients.
All functions of the Langevin package have corresponding help files.
Additionally the package ships a pdf vignette which corresponds to a
[paper](http://dx.doi.org/10.5334/jors.123) published in the Journal of Open
[paper](https://dx.doi.org/10.5334/jors.123) published in the Journal of Open
Research Software.
......@@ -30,7 +30,7 @@ with examples that reproduce the figures from the vignette.
### Installation
Released and tested versions of the Langevin package are available at
[CRAN](http://cran.r-project.org) and can be installed from within R via
[CRAN](https://cran.r-project.org) and can be installed from within R via
```R
install.packages("Langevin")
......
......@@ -44,9 +44,7 @@ system state at \eqn{t+\tau} and the state at \eqn{t}. The average has to be
taken over the whole ensemble or in the stationary case over all \eqn{t =
t_i} with \eqn{X(t_i) = x}. Diffusion can be calculated analogously.
}
\author{
Philip Rinn
}
\references{
\bold{A review of the Langevin method can be found at:}
......@@ -63,4 +61,6 @@ systems}. Phys. Lett. A.
Friedrich, R.; et al. (2000) \emph{Extracting model equations from
experimental data}. Phys. Lett. A.
}
\author{
Philip Rinn
}
......@@ -97,10 +97,9 @@ lines(est$mean_bin, est$mean_bin - est$mean_bin^3, col='red');
plot(est$mean_bin, est$D2);
abline(h=1, col='red');
}
\author{
Philip Rinn
}
\seealso{
\code{\link{Langevin2D}}
}
\author{
Philip Rinn
}
......@@ -77,10 +77,9 @@ label) and each \eqn{\tau} step (column label). Dimension is
\code{Langevin2D} calculates the Drift (with error) and Diffusion matrices
for given time series.
}
\author{
Philip Rinn
}
\seealso{
\code{\link{Langevin1D}}
}
\author{
Philip Rinn
}
......@@ -22,4 +22,3 @@ This method is only implemented for one-dimensional analysis for now.
\author{
Philip Rinn
}
......@@ -24,4 +24,3 @@ print method for class "Langevin".
\author{
Philip Rinn
}
......@@ -25,4 +25,3 @@ summary method for class "Langevin".
\author{
Philip Rinn
}
......@@ -37,10 +37,9 @@ s <- timeseries1D(N=1e4, sf=1, dt=0.01);
t <- 1:1e4;
plot(t, s, t="l", main=paste("mean:", mean(s), " var:", var(s)));
}
\author{
Philip Rinn
}
\seealso{
\code{\link{timeseries2D}}
}
\author{
Philip Rinn
}
......@@ -56,10 +56,9 @@ with \eqn{a_{ij} = 0} for \eqn{ i + j > 5}.
with \eqn{a_{ij} = 0} for \eqn{ i + j > 4}
}
\author{
Philip Rinn
}
\seealso{
\code{\link{timeseries1D}}
}
\author{
Philip Rinn
}
// This file was generated by Rcpp::compileAttributes
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
......@@ -8,42 +8,42 @@ using namespace Rcpp;
// Langevin1D
List Langevin1D(const arma::vec& data, const int& bins, const arma::vec& steps, const double& sf, const int& bin_min, int reqThreads);
RcppExport SEXP Langevin_Langevin1D(SEXP dataSEXP, SEXP binsSEXP, SEXP stepsSEXP, SEXP sfSEXP, SEXP bin_minSEXP, SEXP reqThreadsSEXP) {
RcppExport SEXP _Langevin_Langevin1D(SEXP dataSEXP, SEXP binsSEXP, SEXP stepsSEXP, SEXP sfSEXP, SEXP bin_minSEXP, SEXP reqThreadsSEXP) {
BEGIN_RCPP
Rcpp::RObject __result;
Rcpp::RNGScope __rngScope;
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::vec& >::type data(dataSEXP);
Rcpp::traits::input_parameter< const int& >::type bins(binsSEXP);
Rcpp::traits::input_parameter< const arma::vec& >::type steps(stepsSEXP);
Rcpp::traits::input_parameter< const double& >::type sf(sfSEXP);
Rcpp::traits::input_parameter< const int& >::type bin_min(bin_minSEXP);
Rcpp::traits::input_parameter< int >::type reqThreads(reqThreadsSEXP);
__result = Rcpp::wrap(Langevin1D(data, bins, steps, sf, bin_min, reqThreads));
return __result;
rcpp_result_gen = Rcpp::wrap(Langevin1D(data, bins, steps, sf, bin_min, reqThreads));
return rcpp_result_gen;
END_RCPP
}
// Langevin2D
List Langevin2D(const arma::mat& data, const int& bins, const arma::vec& steps, const double& sf, const int& bin_min, int reqThreads);
RcppExport SEXP Langevin_Langevin2D(SEXP dataSEXP, SEXP binsSEXP, SEXP stepsSEXP, SEXP sfSEXP, SEXP bin_minSEXP, SEXP reqThreadsSEXP) {
RcppExport SEXP _Langevin_Langevin2D(SEXP dataSEXP, SEXP binsSEXP, SEXP stepsSEXP, SEXP sfSEXP, SEXP bin_minSEXP, SEXP reqThreadsSEXP) {
BEGIN_RCPP
Rcpp::RObject __result;
Rcpp::RNGScope __rngScope;
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type data(dataSEXP);
Rcpp::traits::input_parameter< const int& >::type bins(binsSEXP);
Rcpp::traits::input_parameter< const arma::vec& >::type steps(stepsSEXP);
Rcpp::traits::input_parameter< const double& >::type sf(sfSEXP);
Rcpp::traits::input_parameter< const int& >::type bin_min(bin_minSEXP);
Rcpp::traits::input_parameter< int >::type reqThreads(reqThreadsSEXP);
__result = Rcpp::wrap(Langevin2D(data, bins, steps, sf, bin_min, reqThreads));
return __result;
rcpp_result_gen = Rcpp::wrap(Langevin2D(data, bins, steps, sf, bin_min, reqThreads));
return rcpp_result_gen;
END_RCPP
}
// timeseries1D
NumericVector timeseries1D(const unsigned int& N, const double& startpoint, const double& d13, const double& d12, const double& d11, const double& d10, const double& d22, const double& d21, const double& d20, const double& sf, double dt);
RcppExport SEXP Langevin_timeseries1D(SEXP NSEXP, SEXP startpointSEXP, SEXP d13SEXP, SEXP d12SEXP, SEXP d11SEXP, SEXP d10SEXP, SEXP d22SEXP, SEXP d21SEXP, SEXP d20SEXP, SEXP sfSEXP, SEXP dtSEXP) {
RcppExport SEXP _Langevin_timeseries1D(SEXP NSEXP, SEXP startpointSEXP, SEXP d13SEXP, SEXP d12SEXP, SEXP d11SEXP, SEXP d10SEXP, SEXP d22SEXP, SEXP d21SEXP, SEXP d20SEXP, SEXP sfSEXP, SEXP dtSEXP) {
BEGIN_RCPP
Rcpp::RObject __result;
Rcpp::RNGScope __rngScope;
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type N(NSEXP);
Rcpp::traits::input_parameter< const double& >::type startpoint(startpointSEXP);
Rcpp::traits::input_parameter< const double& >::type d13(d13SEXP);
......@@ -55,16 +55,16 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< const double& >::type d20(d20SEXP);
Rcpp::traits::input_parameter< const double& >::type sf(sfSEXP);
Rcpp::traits::input_parameter< double >::type dt(dtSEXP);
__result = Rcpp::wrap(timeseries1D(N, startpoint, d13, d12, d11, d10, d22, d21, d20, sf, dt));
return __result;
rcpp_result_gen = Rcpp::wrap(timeseries1D(N, startpoint, d13, d12, d11, d10, d22, d21, d20, sf, dt));
return rcpp_result_gen;
END_RCPP
}
// timeseries2D
NumericMatrix timeseries2D(const unsigned int& N, const double& startpointx, const double& startpointy, const NumericMatrix& D1_1, const NumericMatrix& D1_2, const NumericMatrix& g_11, const NumericMatrix& g_12, const NumericMatrix& g_21, const NumericMatrix& g_22, const double& sf, double dt);
RcppExport SEXP Langevin_timeseries2D(SEXP NSEXP, SEXP startpointxSEXP, SEXP startpointySEXP, SEXP D1_1SEXP, SEXP D1_2SEXP, SEXP g_11SEXP, SEXP g_12SEXP, SEXP g_21SEXP, SEXP g_22SEXP, SEXP sfSEXP, SEXP dtSEXP) {
RcppExport SEXP _Langevin_timeseries2D(SEXP NSEXP, SEXP startpointxSEXP, SEXP startpointySEXP, SEXP D1_1SEXP, SEXP D1_2SEXP, SEXP g_11SEXP, SEXP g_12SEXP, SEXP g_21SEXP, SEXP g_22SEXP, SEXP sfSEXP, SEXP dtSEXP) {
BEGIN_RCPP
Rcpp::RObject __result;
Rcpp::RNGScope __rngScope;
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const unsigned int& >::type N(NSEXP);
Rcpp::traits::input_parameter< const double& >::type startpointx(startpointxSEXP);
Rcpp::traits::input_parameter< const double& >::type startpointy(startpointySEXP);
......@@ -76,7 +76,20 @@ BEGIN_RCPP
Rcpp::traits::input_parameter< const NumericMatrix& >::type g_22(g_22SEXP);
Rcpp::traits::input_parameter< const double& >::type sf(sfSEXP);
Rcpp::traits::input_parameter< double >::type dt(dtSEXP);
__result = Rcpp::wrap(timeseries2D(N, startpointx, startpointy, D1_1, D1_2, g_11, g_12, g_21, g_22, sf, dt));
return __result;
rcpp_result_gen = Rcpp::wrap(timeseries2D(N, startpointx, startpointy, D1_1, D1_2, g_11, g_12, g_21, g_22, sf, dt));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
{"_Langevin_Langevin1D", (DL_FUNC) &_Langevin_Langevin1D, 6},
{"_Langevin_Langevin2D", (DL_FUNC) &_Langevin_Langevin2D, 6},
{"_Langevin_timeseries1D", (DL_FUNC) &_Langevin_timeseries1D, 11},
{"_Langevin_timeseries2D", (DL_FUNC) &_Langevin_timeseries2D, 11},
{NULL, NULL, 0}
};
RcppExport void R_init_Langevin(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment