Skip to content

Commit

Permalink
fixing C++ One Definition Rule [-Wodr] detected by LTO (part1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmollina committed Mar 5, 2024
1 parent 8281193 commit 2ef4121
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 30 deletions.
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

loglike_hmm_cpp <- function(m, geno, ph1, ph2, rf, verbose) {
.Call('_mappoly_loglike_hmm_cpp', PACKAGE = 'mappoly', m, geno, ph1, ph2, rf, verbose)
}

.vcf_get_probabilities <- function(mat, pl_pos) {
.Call('_mappoly_vcf_get_probabilities', PACKAGE = 'mappoly', mat, pl_pos)
}
Expand Down
14 changes: 6 additions & 8 deletions R/loglike_hmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ loglike_hmm <- function(input.map, input.data = NULL, verbose = FALSE)
D[j, D[j, ] == input.map$info$ploidy + 1] <- dp[j] + dq[j] + 1 + as.numeric(dp[j] == 0 || dq[j] == 0)
for(i in 1:length(input.map$maps)){
rf.temp <- input.map$maps[[i]]$seq.rf
res.temp <- .Call("loglike_hmm",
input.map$info$ploidy,
t(D),
lapply(input.map$maps[[i]]$seq.ph$P, function(x) x-1),
lapply(input.map$maps[[i]]$seq.ph$Q, function(x) x-1),
rf.temp,
verbose,
PACKAGE = "mappoly")
res.temp <- loglike_hmm_cpp(input.map$info$ploidy,
t(D),
lapply(input.map$maps[[i]]$seq.ph$P, function(x) x-1),
lapply(input.map$maps[[i]]$seq.ph$Q, function(x) x-1),
rf.temp,
verbose)
input.map$maps[[i]]$loglike <- res.temp[[1]]
}
return(input.map)
Expand Down
19 changes: 17 additions & 2 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// loglike_hmm_cpp
List loglike_hmm_cpp(int m, NumericMatrix geno, List ph1, List ph2, NumericVector rf, int verbose);
RcppExport SEXP _mappoly_loglike_hmm_cpp(SEXP mSEXP, SEXP genoSEXP, SEXP ph1SEXP, SEXP ph2SEXP, SEXP rfSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< int >::type m(mSEXP);
Rcpp::traits::input_parameter< NumericMatrix >::type geno(genoSEXP);
Rcpp::traits::input_parameter< List >::type ph1(ph1SEXP);
Rcpp::traits::input_parameter< List >::type ph2(ph2SEXP);
Rcpp::traits::input_parameter< NumericVector >::type rf(rfSEXP);
Rcpp::traits::input_parameter< int >::type verbose(verboseSEXP);
rcpp_result_gen = Rcpp::wrap(loglike_hmm_cpp(m, geno, ph1, ph2, rf, verbose));
return rcpp_result_gen;
END_RCPP
}
// vcf_get_probabilities
Rcpp::List vcf_get_probabilities(Rcpp::StringMatrix& mat, int pl_pos);
RcppExport SEXP _mappoly_vcf_get_probabilities(SEXP matSEXP, SEXP pl_posSEXP) {
Expand Down Expand Up @@ -70,13 +86,13 @@ RcppExport SEXP est_hmm_map_single_parent(void *, void *, void *, void *, void *
RcppExport SEXP est_map_hmm(void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP est_map_hmm_highprec(void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP get_counts_single_parent_cpp(void *, void *, void *, void *, void *, void *);
RcppExport SEXP loglike_hmm(void *, void *, void *, void *, void *, void *);
RcppExport SEXP pairwise_rf_estimation_disc(void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP pairwise_rf_estimation_disc_rcpp(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP pairwise_rf_estimation_prob(void *, void *, void *, void *, void *, void *, void *, void *);
RcppExport SEXP poly_hmm_est_CPP(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *);

static const R_CallMethodDef CallEntries[] = {
{"_mappoly_loglike_hmm_cpp", (DL_FUNC) &_mappoly_loglike_hmm_cpp, 6},
{"_mappoly_vcf_get_probabilities", (DL_FUNC) &_mappoly_vcf_get_probabilities, 2},
{"_mappoly_vcf_transform_dosage", (DL_FUNC) &_mappoly_vcf_transform_dosage, 2},
{"_mappoly_vcf_get_ploidy", (DL_FUNC) &_mappoly_vcf_get_ploidy, 2},
Expand All @@ -92,7 +108,6 @@ static const R_CallMethodDef CallEntries[] = {
{"est_map_hmm", (DL_FUNC) &est_map_hmm, 8},
{"est_map_hmm_highprec", (DL_FUNC) &est_map_hmm_highprec, 8},
{"get_counts_single_parent_cpp", (DL_FUNC) &get_counts_single_parent_cpp, 6},
{"loglike_hmm", (DL_FUNC) &loglike_hmm, 6},
{"pairwise_rf_estimation_disc", (DL_FUNC) &pairwise_rf_estimation_disc, 7},
{"pairwise_rf_estimation_disc_rcpp", (DL_FUNC) &pairwise_rf_estimation_disc_rcpp, 12},
{"pairwise_rf_estimation_prob", (DL_FUNC) &pairwise_rf_estimation_prob, 8},
Expand Down
21 changes: 7 additions & 14 deletions src/calc_loglike_given_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,14 @@
using namespace std;
using namespace Rcpp;

RcppExport SEXP loglike_hmm(SEXP ploidyR,
SEXP genoR,
SEXP phPR,
SEXP phQR,
SEXP rfR,
SEXP verboseR)
// [[Rcpp::export]]
List loglike_hmm_cpp(int m,
NumericMatrix geno,
List ph1,
List ph2,
NumericVector rf,
int verbose)
{
//*convert input to C++ types
int m = Rcpp::as<int>(ploidyR);
Rcpp::NumericMatrix geno(genoR); //(n.ind x n.col)
Rcpp::List ph1(phPR);
Rcpp::List ph2(phQR);
Rcpp::NumericVector rf(rfR);
int verbose = Rcpp::as<int>(verboseR);

//*Initializing some variables
int g = nChoosek(m, m/2);
int n_mar = geno.ncol(); // markers are disposed in columns
Expand Down
15 changes: 9 additions & 6 deletions src/calc_loglike_given_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
#include <R_ext/PrtUtil.h>
#include "combinatorial.h"

RcppExport SEXP loglike_hmm(SEXP ploidyR,
SEXP genoR,
SEXP phPR,
SEXP phQR,
SEXP rfR,
SEXP verboseR);
using namespace std;
using namespace Rcpp;

List loglike_hmm_cpp(int m,
NumericMatrix geno,
List ph1,
List ph2,
NumericVector rf,
int verbose);

0 comments on commit 2ef4121

Please sign in to comment.