Hi dear listers,<div><br></div><div>Take the mock function below for an example. What would be the best way to handle computational singularity?</div><div><br></div><div><div><div>#include <R.h></div><div>#include <stdio.h></div>

<div>#include <RcppArmadillo.h></div><div>// [[Rcpp::depends(RcppArmadillo)]]</div><div><br></div><div>using namespace Rcpp;</div><div>using namespace arma;</div><div><br></div><div>RcppExport SEXP foo(SEXP X, SEXP Y){</div>

<div><span class="Apple-tab-span" style="white-space:pre">      </span>arma::mat x=Rcpp::as<arma::mat>(X), y=Rcpp::as<arma::mat>(Y);</div><div><span class="Apple-tab-span" style="white-space:pre">    </span>arma::mat output = arma::solve(x, y );</div>

<div><span class="Apple-tab-span" style="white-space:pre">      </span>return(wrap(output));</div><div>}</div></div></div><div><br></div><div><br></div><div>For instance, if I use the function on the dataset below, R would crash. I read the error handling section of the document in <a href="http://www.jstatsoft.org/v40/i08/paper">http://www.jstatsoft.org/v40/i08/paper</a>, but I am not exactly sure what to do with my situation. Thank you in advance for your help!</div>

<div><br></div><div>x = cbind(1:2, 1:2)</div><div>.Call("foo", x, x)</div><div><br></div><div><br></div>