I'm new to the error-handling in Rcpp. I wonder, how can I stop the error message from showing up in the R console?
Take an example,
In rcpp file:
#include <RcppArmadillo.h>
using namespace arma;
// [[Rcpp::export]]
void chol_c(mat M) {
try {
mat S = (chol(M)).t();
Rcpp::Rcout << S << std::endl;
} catch(...) {
Rcpp::Rcout << "things wrong " << std::endl;
}
}
In R:
> mt0=matrix(c(0.5416, -0.0668 , -0.1538, -0.2435,
+ -0.0668 , 0.9836 , -0.0135 , -0.0195,
+ -0.1538 , -0.0135 , 0.0226 , 0.0334,
+ -0.2435, -0.0195 , 0.0334 , 0.0487),4,byrow = T)
> chol_c(mt0)
error: chol(): decomposition failed
things wrong
My question is how to stop "error: chol(): decomposition failed" from showing up?
My apologies, if the solution is obvious. Thanks!