Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Nov 4, 2024
1 parent 97d1d9c commit 24ffbcc
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 78 deletions.
3 changes: 1 addition & 2 deletions R/JonckheereTerpstra.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ JonckheereTerpstra <- R6Class(
J <- rep.int(seq_len(k)[-1], seq_len(k - 1))

lengths <- tabulate(attr(private$.data, "group"))
lengths_J <- lengths[J]
lengths_IJ <- rep.int(lengths[I], lengths_J)
lengths_IJ <- rep.int(lengths[I], lengths_J <- lengths[J])

private$.statistic_func <- function(data, group) {
split <- split.default(data, group)
Expand Down
5 changes: 3 additions & 2 deletions R/pmt.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ define_pmt <- function(
c(includes, paste0("#include<pmt/", hpps, ".hpp>"))
},
code = {
n <- if (inherit == "rcbd") 2 else 3
args <- paste0("arg_", 1:n)
args <- paste0(
"arg", 1:(n <- if (inherit == "rcbd") 2 else 3)
)
paste0(
"SEXP ", inherit, "_pmt(",
paste("SEXP", args, collapse = ","),
Expand Down
4 changes: 2 additions & 2 deletions inst/include/pmt/progress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class PermuBarHide {
{
double total = n * size;
if (total <= 0 || total > R_XLEN_T_MAX) {
stop("Too many permutations.");
stop("Too many permutations");
}

_statistic_buffer = std::move(NumericVector(no_init(static_cast<R_xlen_t>(total))));
_statistic_buffer = NumericVector(no_init(static_cast<R_xlen_t>(total)));

_buffer_i = 0;
_buffer_size = _statistic_buffer.size();
Expand Down
58 changes: 29 additions & 29 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,105 +11,105 @@ Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// twosample_pmt
NumericVector twosample_pmt(const NumericVector x, const NumericVector y, const Function statistic_func, const double n_permu, const bool progress);
SEXP twosample_pmt(const SEXP x, const SEXP y, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_twosample_pmt(SEXP xSEXP, SEXP ySEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector >::type x(xSEXP);
Rcpp::traits::input_parameter< const NumericVector >::type y(ySEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type x(xSEXP);
Rcpp::traits::input_parameter< const SEXP >::type y(ySEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(twosample_pmt(x, y, statistic_func, n_permu, progress));
return rcpp_result_gen;
END_RCPP
}
// ksample_pmt
NumericVector ksample_pmt(const NumericVector data, const IntegerVector group, const Function statistic_func, const double n_permu, const bool progress);
SEXP ksample_pmt(const SEXP data, const SEXP group, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_ksample_pmt(SEXP dataSEXP, SEXP groupSEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector >::type data(dataSEXP);
Rcpp::traits::input_parameter< const IntegerVector >::type group(groupSEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type data(dataSEXP);
Rcpp::traits::input_parameter< const SEXP >::type group(groupSEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(ksample_pmt(data, group, statistic_func, n_permu, progress));
return rcpp_result_gen;
END_RCPP
}
// multcomp_pmt
NumericVector multcomp_pmt(const IntegerVector group_i, const IntegerVector group_j, const NumericVector data, const IntegerVector group, const Function statistic_func, const double n_permu, const bool progress);
SEXP multcomp_pmt(const SEXP group_i, const SEXP group_j, const SEXP data, const SEXP group, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_multcomp_pmt(SEXP group_iSEXP, SEXP group_jSEXP, SEXP dataSEXP, SEXP groupSEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const IntegerVector >::type group_i(group_iSEXP);
Rcpp::traits::input_parameter< const IntegerVector >::type group_j(group_jSEXP);
Rcpp::traits::input_parameter< const NumericVector >::type data(dataSEXP);
Rcpp::traits::input_parameter< const IntegerVector >::type group(groupSEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type group_i(group_iSEXP);
Rcpp::traits::input_parameter< const SEXP >::type group_j(group_jSEXP);
Rcpp::traits::input_parameter< const SEXP >::type data(dataSEXP);
Rcpp::traits::input_parameter< const SEXP >::type group(groupSEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(multcomp_pmt(group_i, group_j, data, group, statistic_func, n_permu, progress));
return rcpp_result_gen;
END_RCPP
}
// paired_pmt
NumericVector paired_pmt(const NumericVector x, const NumericVector y, const Function statistic_func, const double n_permu, const bool progress);
SEXP paired_pmt(const SEXP x, const SEXP y, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_paired_pmt(SEXP xSEXP, SEXP ySEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector >::type x(xSEXP);
Rcpp::traits::input_parameter< const NumericVector >::type y(ySEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type x(xSEXP);
Rcpp::traits::input_parameter< const SEXP >::type y(ySEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(paired_pmt(x, y, statistic_func, n_permu, progress));
return rcpp_result_gen;
END_RCPP
}
// rcbd_pmt
NumericVector rcbd_pmt(const NumericMatrix data, const Function statistic_func, const double n_permu, const bool progress);
SEXP rcbd_pmt(const SEXP data, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_rcbd_pmt(SEXP dataSEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericMatrix >::type data(dataSEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type data(dataSEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(rcbd_pmt(data, statistic_func, n_permu, progress));
return rcpp_result_gen;
END_RCPP
}
// association_pmt
NumericVector association_pmt(const NumericVector x, const NumericVector y, const Function statistic_func, const double n_permu, const bool progress);
SEXP association_pmt(const SEXP x, const SEXP y, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_association_pmt(SEXP xSEXP, SEXP ySEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const NumericVector >::type x(xSEXP);
Rcpp::traits::input_parameter< const NumericVector >::type y(ySEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type x(xSEXP);
Rcpp::traits::input_parameter< const SEXP >::type y(ySEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(association_pmt(x, y, statistic_func, n_permu, progress));
return rcpp_result_gen;
END_RCPP
}
// table_pmt
NumericVector table_pmt(const IntegerVector row, const IntegerVector col, const Function statistic_func, const double n_permu, const bool progress);
SEXP table_pmt(const SEXP row, const SEXP col, const SEXP statistic_func, const double n_permu, const bool progress);
RcppExport SEXP _LearnNonparam_table_pmt(SEXP rowSEXP, SEXP colSEXP, SEXP statistic_funcSEXP, SEXP n_permuSEXP, SEXP progressSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const IntegerVector >::type row(rowSEXP);
Rcpp::traits::input_parameter< const IntegerVector >::type col(colSEXP);
Rcpp::traits::input_parameter< const Function >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const SEXP >::type row(rowSEXP);
Rcpp::traits::input_parameter< const SEXP >::type col(colSEXP);
Rcpp::traits::input_parameter< const SEXP >::type statistic_func(statistic_funcSEXP);
Rcpp::traits::input_parameter< const double >::type n_permu(n_permuSEXP);
Rcpp::traits::input_parameter< const bool >::type progress(progressSEXP);
rcpp_result_gen = Rcpp::wrap(table_pmt(row, col, statistic_func, n_permu, progress));
Expand Down
86 changes: 43 additions & 43 deletions src/pmt_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,105 +21,105 @@ class ClosFunc : public Function {
#include "pmt/impl_twosample_pmt.hpp"

// [[Rcpp::export]]
NumericVector twosample_pmt(
const NumericVector x,
const NumericVector y,
const Function statistic_func,
SEXP twosample_pmt(
const SEXP x,
const SEXP y,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_twosample_pmt<PermuBarShow>(clone(x), clone(y), ClosFunc(statistic_func), n_permu) :
impl_twosample_pmt<PermuBarHide>(clone(x), clone(y), ClosFunc(statistic_func), n_permu);
impl_twosample_pmt<PermuBarShow, ClosFunc>(clone(x), clone(y), statistic_func, n_permu) :
impl_twosample_pmt<PermuBarHide, ClosFunc>(clone(x), clone(y), statistic_func, n_permu);
}

#include "pmt/impl_ksample_pmt.hpp"

// [[Rcpp::export]]
NumericVector ksample_pmt(
const NumericVector data,
const IntegerVector group,
const Function statistic_func,
SEXP ksample_pmt(
const SEXP data,
const SEXP group,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_ksample_pmt<PermuBarShow>(data, clone(group), ClosFunc(statistic_func), n_permu) :
impl_ksample_pmt<PermuBarHide>(data, clone(group), ClosFunc(statistic_func), n_permu);
impl_ksample_pmt<PermuBarShow, ClosFunc>(data, clone(group), statistic_func, n_permu) :
impl_ksample_pmt<PermuBarHide, ClosFunc>(data, clone(group), statistic_func, n_permu);
}

#include "pmt/impl_multcomp_pmt.hpp"

// [[Rcpp::export]]
NumericVector multcomp_pmt(
const IntegerVector group_i,
const IntegerVector group_j,
const NumericVector data,
const IntegerVector group,
const Function statistic_func,
SEXP multcomp_pmt(
const SEXP group_i,
const SEXP group_j,
const SEXP data,
const SEXP group,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_multcomp_pmt<PermuBarShow>(group_i, group_j, data, clone(group), ClosFunc(statistic_func), n_permu) :
impl_multcomp_pmt<PermuBarHide>(group_i, group_j, data, clone(group), ClosFunc(statistic_func), n_permu);
impl_multcomp_pmt<PermuBarShow, ClosFunc>(group_i, group_j, data, clone(group), statistic_func, n_permu) :
impl_multcomp_pmt<PermuBarHide, ClosFunc>(group_i, group_j, data, clone(group), statistic_func, n_permu);
}

#include "pmt/impl_paired_pmt.hpp"

// [[Rcpp::export]]
NumericVector paired_pmt(
const NumericVector x,
const NumericVector y,
const Function statistic_func,
SEXP paired_pmt(
const SEXP x,
const SEXP y,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_paired_pmt<PermuBarShow>(clone(x), clone(y), ClosFunc(statistic_func), n_permu) :
impl_paired_pmt<PermuBarHide>(clone(x), clone(y), ClosFunc(statistic_func), n_permu);
impl_paired_pmt<PermuBarShow, ClosFunc>(clone(x), clone(y), statistic_func, n_permu) :
impl_paired_pmt<PermuBarHide, ClosFunc>(clone(x), clone(y), statistic_func, n_permu);
}

#include "pmt/impl_rcbd_pmt.hpp"

// [[Rcpp::export]]
NumericVector rcbd_pmt(
const NumericMatrix data,
const Function statistic_func,
SEXP rcbd_pmt(
const SEXP data,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_rcbd_pmt<PermuBarShow>(clone(data), ClosFunc(statistic_func), n_permu) :
impl_rcbd_pmt<PermuBarHide>(clone(data), ClosFunc(statistic_func), n_permu);
impl_rcbd_pmt<PermuBarShow, ClosFunc>(clone(data), statistic_func, n_permu) :
impl_rcbd_pmt<PermuBarHide, ClosFunc>(clone(data), statistic_func, n_permu);
}

#include "pmt/impl_association_pmt.hpp"

// [[Rcpp::export]]
NumericVector association_pmt(
const NumericVector x,
const NumericVector y,
const Function statistic_func,
SEXP association_pmt(
const SEXP x,
const SEXP y,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_association_pmt<PermuBarShow>(x, clone(y), ClosFunc(statistic_func), n_permu) :
impl_association_pmt<PermuBarHide>(x, clone(y), ClosFunc(statistic_func), n_permu);
impl_association_pmt<PermuBarShow, ClosFunc>(x, clone(y), statistic_func, n_permu) :
impl_association_pmt<PermuBarHide, ClosFunc>(x, clone(y), statistic_func, n_permu);
}

#include "pmt/impl_table_pmt.hpp"

// [[Rcpp::export]]
NumericVector table_pmt(
const IntegerVector row,
const IntegerVector col,
const Function statistic_func,
SEXP table_pmt(
const SEXP row,
const SEXP col,
const SEXP statistic_func,
const double n_permu,
const bool progress)
{
return progress ?
impl_table_pmt<PermuBarShow>(row, clone(col), ClosFunc(statistic_func), n_permu) :
impl_table_pmt<PermuBarHide>(row, clone(col), ClosFunc(statistic_func), n_permu);
impl_table_pmt<PermuBarShow, ClosFunc>(row, clone(col), statistic_func, n_permu) :
impl_table_pmt<PermuBarHide, ClosFunc>(row, clone(col), statistic_func, n_permu);
}

0 comments on commit 24ffbcc

Please sign in to comment.