Skip to content

Commit

Permalink
perf: use reference passing const in c_gonen
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke committed Aug 23, 2024
1 parent 7f6354e commit fceced5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/survival_scores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ float c_concordance(NumericVector time, NumericVector status, NumericVector cran
}

// [[Rcpp::export]]
double c_gonen(NumericVector crank, float tiex) {
// NOTE: we assume crank to be sorted!
double c_gonen(const NumericVector crank&, float tiex) {
// NOTE: we assume crank to be sorted!
const int n = crank.length();
double ghci = 0.0;

for (int i = 0; i < n - 1; i++) {
double ci = crank[i];
const double ci = crank[i];
for (int j = i + 1; j < n; j++) {
double cj = crank[j];
const double cj = crank[j];
ghci += ((ci < cj) ? 1 : tiex) / (1 + exp(ci - cj));
}
}
Expand Down

0 comments on commit fceced5

Please sign in to comment.