-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
6f459b7
commit 2e27512
Showing
4 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Generated by using Rcpp::compileAttributes() -> do not edit by hand | ||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 | ||
|
||
#include <Rcpp.h> | ||
|
||
using namespace Rcpp; | ||
|
||
// blr_pairs_cpp | ||
DataFrame blr_pairs_cpp(NumericVector x, NumericVector y); | ||
RcppExport SEXP _blorr_blr_pairs_cpp(SEXP xSEXP, SEXP ySEXP) { | ||
BEGIN_RCPP | ||
Rcpp::RObject rcpp_result_gen; | ||
Rcpp::RNGScope rcpp_rngScope_gen; | ||
Rcpp::traits::input_parameter< NumericVector >::type x(xSEXP); | ||
Rcpp::traits::input_parameter< NumericVector >::type y(ySEXP); | ||
rcpp_result_gen = Rcpp::wrap(blr_pairs_cpp(x, y)); | ||
return rcpp_result_gen; | ||
END_RCPP | ||
} | ||
|
||
static const R_CallMethodDef CallEntries[] = { | ||
{"_blorr_blr_pairs_cpp", (DL_FUNC) &_blorr_blr_pairs_cpp, 2}, | ||
{NULL, NULL, 0} | ||
}; | ||
|
||
RcppExport void R_init_blorr(DllInfo *dll) { | ||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); | ||
R_useDynamicSymbols(dll, FALSE); | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <Rcpp.h> | ||
using namespace Rcpp; | ||
|
||
// [[Rcpp::plugins("cpp11")]] | ||
// [[Rcpp::export]] | ||
DataFrame blr_pairs_cpp(NumericVector x, NumericVector y) { | ||
|
||
// loop counters | ||
int n1 = x.size(); | ||
int n2 = y.size(); | ||
|
||
// count pairs | ||
int pairs_count = 0; | ||
int concordant = 0; | ||
int discordant = 0; | ||
int ties = 0; | ||
|
||
// compute | ||
for(int i = 0; i < n1; i++) { | ||
for(int j = 0; j < n2; j++) { | ||
|
||
pairs_count++; | ||
|
||
if (x[i] > y[j]) { | ||
concordant++; | ||
} else if (x[i] == y[j]) { | ||
ties++; | ||
} else { | ||
discordant++; | ||
} | ||
|
||
} | ||
} | ||
|
||
DataFrame df = DataFrame::create(Named("pairs") = pairs_count, | ||
Named("concordant") = concordant, | ||
Named("discordant") = discordant, | ||
Named("ties") = ties); | ||
|
||
return df; | ||
|
||
} | ||
|
Binary file not shown.