Skip to content

Commit

Permalink
pass matrix by reference in kendall_cor
Browse files Browse the repository at this point in the history
  • Loading branch information
pachadotdev committed Jul 4, 2024
1 parent 82819f9 commit fec825f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ importFrom(rlang,":=")
importFrom(rlang,sym)
importFrom(stats,as.formula)
importFrom(stats,binomial)
importFrom(stats,complete.cases)
importFrom(stats,gaussian)
importFrom(stats,model.matrix)
importFrom(stats,na.omit)
Expand Down
4 changes: 3 additions & 1 deletion R/capybara-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
#' and Wanner (2020).
#'
#' @name capybara-package
#' @importFrom dplyr across all_of filter group_by mutate pull select summarise ungroup vars
#' @importFrom dplyr across all_of filter group_by mutate pull select summarise
#' ungroup vars
#' @importFrom Formula Formula
#' @importFrom MASS negative.binomial theta.ml
#' @importFrom rlang sym :=
#' @importFrom stats as.formula binomial model.matrix na.omit gaussian poisson
#' pnorm printCoefmat rgamma rlogis rnorm rpois terms vcov predict
#' complete.cases
#' @importFrom utils combn
#' @useDynLib capybara, .registration = TRUE
"_PACKAGE"
Expand Down
2 changes: 1 addition & 1 deletion src/05_kendall_correlation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ uint64_t merge_sort_(double *x, double *buf, size_t len) {
return swaps;
}

[[cpp11::register]] double kendall_cor_(doubles_matrix<> m) {
[[cpp11::register]] double kendall_cor_(const doubles_matrix<> &m) {
size_t len = m.nrow();
std::vector<double> arr1(len), arr2(len);
std::vector<double> buf(len);
Expand Down
4 changes: 2 additions & 2 deletions src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ extern "C" SEXP _capybara_sqrt_(SEXP w) {
END_CPP11
}
// 05_kendall_correlation.cpp
double kendall_cor_(doubles_matrix<> m);
double kendall_cor_(const doubles_matrix<> & m);
extern "C" SEXP _capybara_kendall_cor_(SEXP m) {
BEGIN_CPP11
return cpp11::as_sexp(kendall_cor_(cpp11::as_cpp<cpp11::decay_t<doubles_matrix<>>>(m)));
return cpp11::as_sexp(kendall_cor_(cpp11::as_cpp<cpp11::decay_t<const doubles_matrix<> &>>(m)));
END_CPP11
}

Expand Down

0 comments on commit fec825f

Please sign in to comment.