diff --git a/R/pmt.R b/R/pmt.R index 559d15b..845abe3 100644 --- a/R/pmt.R +++ b/R/pmt.R @@ -159,8 +159,8 @@ pmts <- function( #' inherit = "twosample", #' n_permu = 1e5, #' statistic = "[](const NumericVector& x, const NumericVector& y) { -#' R_len_t m = x.size(); -#' R_len_t n = y.size(); +#' R_xlen_t m = x.size(); +#' R_xlen_t n = y.size(); #' return [=](const NumericVector& x, const NumericVector& y) -> double { #' return sum(x) / m - sum(y) / n; #' }; diff --git a/inst/include/pmt/impl_multcomp_pmt.hpp b/inst/include/pmt/impl_multcomp_pmt.hpp index 5bf5e5a..f8e0d56 100644 --- a/inst/include/pmt/impl_multcomp_pmt.hpp +++ b/inst/include/pmt/impl_multcomp_pmt.hpp @@ -7,8 +7,8 @@ RObject impl_multcomp_pmt( const T& statistic_func, const double n_permu) { - R_len_t n_group = group[group.size() - 1]; - R_len_t n_pair = n_group * (n_group - 1) / 2; + R_xlen_t n_group = group[group.size() - 1]; + R_xlen_t n_pair = n_group * (n_group - 1) / 2; Stat<progress> statistic_container(n_pair); @@ -16,7 +16,7 @@ RObject impl_multcomp_pmt( auto statistic_closure = statistic_func(data, group); bool flag = false; - for (R_len_t k = 0; k < n_pair; k++) { + for (R_xlen_t k = 0; k < n_pair; k++) { flag = statistic_container << statistic_closure(group_i[k], group_j[k]); }; diff --git a/inst/include/pmt/impl_paired_pmt.hpp b/inst/include/pmt/impl_paired_pmt.hpp index 049c079..29dcb0c 100644 --- a/inst/include/pmt/impl_paired_pmt.hpp +++ b/inst/include/pmt/impl_paired_pmt.hpp @@ -15,13 +15,15 @@ RObject impl_paired_pmt( statistic_container.init_statistic(paired_update); if (!std::isnan(n_permu)) { - R_len_t i = 0; - R_len_t n = x.size(); + R_xlen_t n = x.size(); + R_xlen_t i; if (n_permu == 0) { statistic_container.init_statistic_permu(1 << n); IntegerVector swapped(n, 0); + + i = 0; while (i < n) { if (i == 0) { paired_update(); diff --git a/inst/include/pmt/impl_rcbd_pmt.hpp b/inst/include/pmt/impl_rcbd_pmt.hpp index 5be5b9b..7d4061e 100644 --- a/inst/include/pmt/impl_rcbd_pmt.hpp +++ b/inst/include/pmt/impl_rcbd_pmt.hpp @@ -14,7 +14,7 @@ RObject impl_rcbd_pmt( statistic_container.init_statistic(rcbd_update); if (!std::isnan(n_permu)) { - R_len_t k = data.nrow(); + R_xlen_t k = data.nrow(); auto begin = data.begin(); auto end = data.end() - k; diff --git a/inst/include/pmt/impl_table_pmt.hpp b/inst/include/pmt/impl_table_pmt.hpp index d58513f..611496b 100644 --- a/inst/include/pmt/impl_table_pmt.hpp +++ b/inst/include/pmt/impl_table_pmt.hpp @@ -7,13 +7,13 @@ RObject impl_table_pmt( { Stat<progress> statistic_container; - R_len_t n = row.size(); + R_xlen_t n = row.size(); IntegerMatrix data(no_init(row[n - 1] + 1, col[n - 1] + 1)); auto data_filled = [data, row, col, n]() mutable { data.fill(0); - for (R_len_t i = 0; i < n; i++) { + for (R_xlen_t i = 0; i < n; i++) { data(row[i], col[i])++; } return data; diff --git a/inst/include/pmt/impl_twosample_pmt.hpp b/inst/include/pmt/impl_twosample_pmt.hpp index f34146c..9dd0f65 100644 --- a/inst/include/pmt/impl_twosample_pmt.hpp +++ b/inst/include/pmt/impl_twosample_pmt.hpp @@ -18,10 +18,10 @@ RObject impl_twosample_pmt( NumericVector x_ = x.size() < y.size() ? x : y; NumericVector y_ = x.size() < y.size() ? y : x; - R_len_t m = x_.size(); - R_len_t n = x_.size() + y_.size(); + R_xlen_t m = x_.size(); + R_xlen_t n = x_.size() + y_.size(); - R_len_t i, j; + R_xlen_t i, j; if (n_permu == 0) { IntegerVector p(n, 0); @@ -33,7 +33,7 @@ RObject impl_twosample_pmt( for (i = 0; i < n; i++) { p[i] = i; } - auto swap_update = [x_, y_, p, m, &twosample_update](const R_len_t out, const R_len_t in) mutable { + auto swap_update = [x_, y_, p, m, &twosample_update](const R_xlen_t out, const R_xlen_t in) mutable { std::swap(x_[p[out]], y_[p[in] - m]); std::swap(p[out], p[in]); twosample_update(); diff --git a/inst/include/pmt/progress.hpp b/inst/include/pmt/progress.hpp index bbf5e25..008bedf 100644 --- a/inst/include/pmt/progress.hpp +++ b/inst/include/pmt/progress.hpp @@ -35,7 +35,7 @@ constexpr auto generated_bars = generate_bars(std::make_integer_sequence<unsigne template <bool progress> class Stat { public: - Stat(R_len_t statistic_size = 1) : + Stat(R_xlen_t statistic_size = 1) : _progress_i(0), _progress_every(2), _statistic_size(statistic_size) { } @@ -87,9 +87,9 @@ class Stat { R_xlen_t _progress_i; R_xlen_t _progress_every; - R_len_t _statistic_size; + R_xlen_t _statistic_size; - void _init_statistic_buffer(double n, R_len_t size) + void _init_statistic_buffer(double n, R_xlen_t size) { double total = n * size; if (total <= 0 || total > R_XLEN_T_MAX) { diff --git a/man/pmt.Rd b/man/pmt.Rd index 0bbf8be..ef20cb9 100644 --- a/man/pmt.Rd +++ b/man/pmt.Rd @@ -118,8 +118,8 @@ rcpp <- define_pmt( inherit = "twosample", n_permu = 1e5, statistic = "[](const NumericVector& x, const NumericVector& y) { - R_len_t m = x.size(); - R_len_t n = y.size(); + R_xlen_t m = x.size(); + R_xlen_t n = y.size(); return [=](const NumericVector& x, const NumericVector& y) -> double { return sum(x) / m - sum(y) / n; };