From c0e2fa25f4e1997b55747c7fa7e59634414a857f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Ucar?= Date: Sat, 28 Mar 2026 11:24:49 +0100 Subject: [PATCH 1/2] Simplify Rfast_mahaCpp by removing redundant exception handling --- src/maha_ex.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/maha_ex.cpp b/src/maha_ex.cpp index 41621e0..1f53f8f 100644 --- a/src/maha_ex.cpp +++ b/src/maha_ex.cpp @@ -12,24 +12,14 @@ NumericVector mahaInt(arma::mat& X, arma::vec& mu, arma::mat& sigma, const bool */ RcppExport SEXP Rfast_mahaCpp(SEXP XSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP isCholSEXP) { BEGIN_RCPP - RObject __result = wrap(NA_REAL); RNGScope __rngScope; NumericMatrix X(XSEXP); NumericVector mu(muSEXP); NumericMatrix sigma(sigmaSEXP); traits::input_parameter::type isChol(isCholSEXP); - try { arma::mat X_(X.begin(), X.nrow(), X.ncol(), false), sigma_(sigma.begin(), sigma.nrow(), sigma.ncol(), false); arma::vec mu_(mu.begin(), mu.size(), false); - NumericVector dist = mahaInt(X_, mu_, sigma_, isChol); - __result = dist; - - } catch (std::exception& __ex__) { - forward_exception_to_r(__ex__); - } catch (...) { - ::Rf_error("c++ exception (unknown reason)"); - } - return __result; + return mahaInt(X_, mu_, sigma_, isChol); END_RCPP -} \ No newline at end of file +} From 642f2712529cc63d4422f52447136a0139079f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1aki=20Ucar?= Date: Sat, 28 Mar 2026 11:40:51 +0100 Subject: [PATCH 2/2] Add missing wrap --- src/maha_ex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/maha_ex.cpp b/src/maha_ex.cpp index 1f53f8f..97de91a 100644 --- a/src/maha_ex.cpp +++ b/src/maha_ex.cpp @@ -20,6 +20,6 @@ RcppExport SEXP Rfast_mahaCpp(SEXP XSEXP, SEXP muSEXP, SEXP sigmaSEXP, SEXP isCh arma::mat X_(X.begin(), X.nrow(), X.ncol(), false), sigma_(sigma.begin(), sigma.nrow(), sigma.ncol(), false); arma::vec mu_(mu.begin(), mu.size(), false); - return mahaInt(X_, mu_, sigma_, isChol); + return wrap(mahaInt(X_, mu_, sigma_, isChol)); END_RCPP }