@@ -20,13 +20,8 @@ class CachedFunc : public Function {
2020 template <typename ... Args>
2121 auto operator ()(Args&&... args) const
2222 {
23- return fast_invoker (Function::operator ()(std::forward<Args>(args)...), std::forward<Args>(args)...);
24- }
23+ Shield<SEXP > closure = Function::operator ()(std::forward<Args>(args)...)
2524
26- protected:
27- template <typename ... Args>
28- auto fast_invoker (SEXP closure, Args&&... args) const
29- {
3025#if defined(R_VERSION) && R_VERSION >= R_Version(4, 5, 0)
3126 Shield<SEXP > closure_formals (R_ClosureFormals (closure)), closure_body (R_ClosureBody (closure)), closure_envir (R_ClosureEnv (closure));
3227#else
@@ -96,22 +91,15 @@ SEXP ksample_pmt(
9691 impl_ksample_pmt<false , CachedFunc<double >>(data, clone (group), statistic_func, n_permu);
9792}
9893
99- #include " pmt/impl_multcomp_pmt.hpp"
100-
101- template <typename T>
10294class MultcompFunc : public CachedFunc <SEXP > {
10395public:
10496 using CachedFunc<SEXP >::CachedFunc;
10597
10698 template <typename ... Args>
10799 auto operator ()(Args&&... args) const
108100 {
109- return [statistic_closure = CachedFunc<SEXP >::operator ()(std::forward<Args>(args)...), i = RObject (Rf_allocVector (INTSXP , 1 )), j = RObject (Rf_allocVector (INTSXP , 1 )), this ](auto &&...) {
110- return [pairwise_closure = this ->fast_invoker (statistic_closure (), i, j), i_ptr = INTEGER (i), j_ptr = INTEGER (j)](int i, int j) {
111- *i_ptr = i;
112- *j_ptr = j;
113- return as<T>(pairwise_closure ());
114- };
101+ return [statistic_closure = CachedFunc<SEXP >::operator ()(std::forward<Args>(args)...)](auto &&... args) {
102+ return REAL (statistic_closure (std::forward<decltype (args)>(args)...));
115103 };
116104 }
117105};
@@ -125,8 +113,8 @@ SEXP multcomp_pmt(
125113 const bool progress)
126114{
127115 return progress ?
128- impl_multcomp_pmt<true , MultcompFunc< double > >(data, clone (group), statistic_func, n_permu) :
129- impl_multcomp_pmt<false , MultcompFunc< double > >(data, clone (group), statistic_func, n_permu);
116+ impl_multcomp_pmt<true , MultcompFunc>(data, clone (group), statistic_func, n_permu) :
117+ impl_multcomp_pmt<false , MultcompFunc>(data, clone (group), statistic_func, n_permu);
130118}
131119
132120#include " pmt/impl_paired_pmt.hpp"
0 commit comments