Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

with .registration=TRUE, change C++ fastLm to fastLm_impl (closes #163) #164

Merged
merged 1 commit into from
Aug 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

fastLm <- function(X, y) {
.Call(RcppArmadillo_fastLm, X, y)
fastLm_impl <- function(X, y) {
.Call(`_RcppArmadillo_fastLm_impl`, X, y)
}

#' Report the version of Armadillo
Expand All @@ -14,7 +14,7 @@ fastLm <- function(X, y) {
#' or a named vector with three elements \code{major}, \code{minor} and \code{patch}.
#' @seealso Armadillo header file \code{arma_version.hpp}.
armadillo_version <- function(single) {
.Call(RcppArmadillo_armadillo_version, single)
.Call(`_RcppArmadillo_armadillo_version`, single)
}

#' Set the Armadillo Random Number Generator to a random value
Expand All @@ -33,7 +33,7 @@ armadillo_version <- function(single) {
#' as the one from R.
#' @seealso The R documentation on its RNGs all of which are accessible via \pkg{Rcpp}.
armadillo_set_seed_random <- function() {
invisible(.Call(RcppArmadillo_armadillo_set_seed_random))
invisible(.Call(`_RcppArmadillo_armadillo_set_seed_random`))
}

#' Set the Armadillo Random Number Generator to the given value
Expand All @@ -53,6 +53,6 @@ armadillo_set_seed_random <- function() {
#' as the one from R.
#' @seealso The R documentation on its RNGs all of which are accessible via \pkg{Rcpp}.
armadillo_set_seed <- function(val) {
invisible(.Call(RcppArmadillo_armadillo_set_seed, val))
invisible(.Call(`_RcppArmadillo_armadillo_set_seed`, val))
}

4 changes: 2 additions & 2 deletions R/fastLm.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## fastLm.R: Rcpp/Armadillo implementation of lm()
##
## Copyright (C) 2010 - 2013 Dirk Eddelbuettel, Romain Francois and Douglas Bates
## Copyright (C) 2010 - 2017 Dirk Eddelbuettel, Romain Francois and Douglas Bates
##
## This file is part of RcppArmadillo.
##
Expand All @@ -21,7 +21,7 @@ fastLmPure <- function(X, y) {

stopifnot(is.matrix(X), is.numeric(y), nrow(y)==nrow(X))

.Call( "RcppArmadillo_fastLm", X, y, PACKAGE = "RcppArmadillo" )
.Call(`_RcppArmadillo_fastLm_impl`, X, y)
}

fastLm <- function(X, ...) UseMethod("fastLm")
Expand Down
9 changes: 3 additions & 6 deletions inst/unitTests/runit.fastLm.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/r -t
#
# Copyright (C) 2010 - 2012 Dirk Eddelbuettel, Romain Francois and Douglas Bates
# Copyright (C) 2010 - 2017 Dirk Eddelbuettel, Romain Francois and Douglas Bates
#
# This file is part of RcppArmadillo.
#
Expand All @@ -21,11 +21,8 @@

test.fastLm <- function() {
data(trees, package="datasets")
flm <- .Call( "RcppArmadillo_fastLm",
cbind(1, log(trees$Girth)),
log(trees$Volume),
PACKAGE = "RcppArmadillo"
)
flm <- fastLmPure(cbind(1, log(trees$Girth)),
log(trees$Volume))
fit <- lm(log(Volume) ~ log(Girth), data=trees)

checkEquals(as.numeric(flm$coefficients), as.numeric(coef(fit)),
Expand Down
1 change: 1 addition & 0 deletions man/fastLm.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{fastLm}
\alias{fastLm}
\alias{fastLm_cpp}
\alias{fastLmPure}
\alias{fastLm.default}
\alias{fastLm.formula}
Expand Down
22 changes: 11 additions & 11 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@

using namespace Rcpp;

// fastLm
List fastLm(const arma::mat& X, const arma::colvec& y);
RcppExport SEXP RcppArmadillo_fastLm(SEXP XSEXP, SEXP ySEXP) {
// fastLm_impl
List fastLm_impl(const arma::mat& X, const arma::colvec& y);
RcppExport SEXP _RcppArmadillo_fastLm_impl(SEXP XSEXP, SEXP ySEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type X(XSEXP);
Rcpp::traits::input_parameter< const arma::colvec& >::type y(ySEXP);
rcpp_result_gen = Rcpp::wrap(fastLm(X, y));
rcpp_result_gen = Rcpp::wrap(fastLm_impl(X, y));
return rcpp_result_gen;
END_RCPP
}
// armadillo_version
IntegerVector armadillo_version(bool single);
RcppExport SEXP RcppArmadillo_armadillo_version(SEXP singleSEXP) {
RcppExport SEXP _RcppArmadillo_armadillo_version(SEXP singleSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -31,7 +31,7 @@ END_RCPP
}
// armadillo_set_seed_random
void armadillo_set_seed_random();
RcppExport SEXP RcppArmadillo_armadillo_set_seed_random() {
RcppExport SEXP _RcppArmadillo_armadillo_set_seed_random() {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
armadillo_set_seed_random();
Expand All @@ -40,7 +40,7 @@ END_RCPP
}
// armadillo_set_seed
void armadillo_set_seed(unsigned int val);
RcppExport SEXP RcppArmadillo_armadillo_set_seed(SEXP valSEXP) {
RcppExport SEXP _RcppArmadillo_armadillo_set_seed(SEXP valSEXP) {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< unsigned int >::type val(valSEXP);
Expand All @@ -50,10 +50,10 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"RcppArmadillo_fastLm", (DL_FUNC) &RcppArmadillo_fastLm, 2},
{"RcppArmadillo_armadillo_version", (DL_FUNC) &RcppArmadillo_armadillo_version, 1},
{"RcppArmadillo_armadillo_set_seed_random", (DL_FUNC) &RcppArmadillo_armadillo_set_seed_random, 0},
{"RcppArmadillo_armadillo_set_seed", (DL_FUNC) &RcppArmadillo_armadillo_set_seed, 1},
{"_RcppArmadillo_fastLm_impl", (DL_FUNC) &_RcppArmadillo_fastLm_impl, 2},
{"_RcppArmadillo_armadillo_version", (DL_FUNC) &_RcppArmadillo_armadillo_version, 1},
{"_RcppArmadillo_armadillo_set_seed_random", (DL_FUNC) &_RcppArmadillo_armadillo_set_seed_random, 0},
{"_RcppArmadillo_armadillo_set_seed", (DL_FUNC) &_RcppArmadillo_armadillo_set_seed, 1},
{NULL, NULL, 0}
};

Expand Down
2 changes: 1 addition & 1 deletion src/fastLm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using namespace Rcpp;

// [[Rcpp::export]]
List fastLm(const arma::mat& X, const arma::colvec& y) {
List fastLm_impl(const arma::mat& X, const arma::colvec& y) {
int n = X.n_rows, k = X.n_cols;

arma::colvec coef = arma::solve(X, y); // fit model y ~ X
Expand Down