Skip to content

Commit

Permalink
use R_xlen_t everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
qddyy committed Dec 15, 2024
1 parent 47a1e13 commit dc2817e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions R/pmt.R
Original file line number Diff line number Diff line change
Expand Up @@ -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;
#' };
Expand Down
6 changes: 3 additions & 3 deletions inst/include/pmt/impl_multcomp_pmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ 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);

auto multcomp_update = [group_i, group_j, data, group, n_pair, &statistic_func, &statistic_container]() {
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]);
};

Expand Down
6 changes: 4 additions & 2 deletions inst/include/pmt/impl_paired_pmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion inst/include/pmt/impl_rcbd_pmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions inst/include/pmt/impl_table_pmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions inst/include/pmt/impl_twosample_pmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions inst/include/pmt/progress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions man/pmt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dc2817e

Please sign in to comment.