-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
238 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,52 @@ | ||
#include "utils.h" | ||
#include <Rcpp.h> | ||
#include <algorithm> | ||
#include <cli/progress.h> | ||
|
||
using namespace Rcpp; | ||
|
||
inline void association_do( | ||
int i, | ||
NumericVector x, | ||
NumericVector y, | ||
Function statistic_func, | ||
NumericVector statistic_permu, | ||
RObject bar) | ||
void association_do( | ||
unsigned& i, | ||
const NumericVector& x, | ||
const NumericVector& y, | ||
const Function& statistic_func, | ||
NumericVector& statistic_permu, | ||
RObject& bar) | ||
{ | ||
statistic_permu[i] = as<double>(statistic_func(x, y)); | ||
|
||
if (CLI_SHOULD_TICK) { | ||
cli_progress_set(bar, i); | ||
} | ||
update_bar(i, bar); | ||
i++; | ||
} | ||
|
||
// [[Rcpp::export]] | ||
NumericVector association_pmt( | ||
NumericVector x, | ||
const NumericVector x, | ||
NumericVector y, | ||
Function statistic_func, | ||
int n_permu) | ||
const Function statistic_func, | ||
const unsigned n_permu) | ||
{ | ||
int total; | ||
unsigned total; | ||
if (n_permu == 0) { | ||
total = n_permutation(y); | ||
} else { | ||
total = n_permu; | ||
} | ||
|
||
NumericVector statistic_permu(total); | ||
RObject bar = cli_progress_bar(total, NULL); | ||
RObject bar = create_bar(total); | ||
|
||
unsigned i = 0; | ||
if (n_permu == 0) { | ||
int i = 0; | ||
do { | ||
association_do(i, x, y, statistic_func, statistic_permu, bar); | ||
i++; | ||
} while (std::next_permutation(y.begin(), y.end())); | ||
} while (next_permutation(y)); | ||
} else { | ||
for (int i = 0; i < total; i++) { | ||
while (i < total) { | ||
random_shuffle(y); | ||
association_do(i, x, y, statistic_func, statistic_permu, bar); | ||
} | ||
} | ||
|
||
cli_progress_done(bar); | ||
close_bar(bar); | ||
|
||
return statistic_permu; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,52 @@ | ||
#include "utils.h" | ||
#include <Rcpp.h> | ||
#include <algorithm> | ||
#include <cli/progress.h> | ||
|
||
using namespace Rcpp; | ||
|
||
inline void ksample_do( | ||
int i, | ||
NumericVector data, | ||
IntegerVector group, | ||
Function statistic_func, | ||
NumericVector statistic_permu, | ||
RObject bar) | ||
void ksample_do( | ||
unsigned& i, | ||
const NumericVector& data, | ||
const IntegerVector& group, | ||
const Function& statistic_func, | ||
NumericVector& statistic_permu, | ||
RObject& bar) | ||
{ | ||
statistic_permu[i] = as<double>(statistic_func(data, group)); | ||
|
||
if (CLI_SHOULD_TICK) { | ||
cli_progress_set(bar, i); | ||
} | ||
update_bar(i, bar); | ||
i++; | ||
} | ||
|
||
// [[Rcpp::export]] | ||
NumericVector ksample_pmt( | ||
NumericVector data, | ||
const NumericVector data, | ||
IntegerVector group, | ||
Function statistic_func, | ||
int n_permu) | ||
const Function statistic_func, | ||
const unsigned n_permu) | ||
{ | ||
int total; | ||
unsigned total; | ||
if (n_permu == 0) { | ||
total = n_permutation(group); | ||
} else { | ||
total = n_permu; | ||
} | ||
|
||
NumericVector statistic_permu(total); | ||
RObject bar = cli_progress_bar(total, NULL); | ||
RObject bar = create_bar(total); | ||
|
||
unsigned i = 0; | ||
if (n_permu == 0) { | ||
int i = 0; | ||
do { | ||
ksample_do(i, data, group, statistic_func, statistic_permu, bar); | ||
i++; | ||
} while (std::next_permutation(group.begin(), group.end())); | ||
} while (next_permutation(group)); | ||
} else { | ||
for (int i = 0; i < total; i++) { | ||
while (i < total) { | ||
random_shuffle(group); | ||
ksample_do(i, data, group, statistic_func, statistic_permu, bar); | ||
} | ||
} | ||
|
||
cli_progress_done(bar); | ||
close_bar(bar); | ||
|
||
return statistic_permu; | ||
} |
Oops, something went wrong.